increment.cgi

 


#!/usr/bin/perl

@pairs = split(/&/, $ENV{'QUERY_STRING'});

foreach $pair (@pairs) 
{
    ($key, $value) = split (/=/, $pair);
    $key =~ tr/+/ /;
    $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~s/<!--(.|\n)*-->//g;
	
    if ($formdata{$key}) 
    {
        $formdata{$key} .= ", $value";
    } 
    else 
    {
        $formdata{$key} = $value;
    }
}



print "Content-type: text/html\n\n";


$counter = $formdata{'counter'};

++$counter;

print "Your number incremented by 1 is $counter";
$watch = ++$counter;
print "<BR>Your number, incremented again by 1, is now $counter. If we store that operation, its value is also $watch.";

$counter = $formdata{'counter'};
print "<HR>Let's start over, with your original number $counter";
$counter++;
print "<BR>Again, your number incremented by 1 is $counter";
$watch = $counter++;
print "<BR>Now we store the value of your number in a second variable, which is now equal to $watch, and then we increment your number again. It's now $counter.";