#!/usr/local/bin/perl
#where's Wally converted to a cgi program
# Print out a content-type for HTTP/1.0 compatibility
print "Content-type:text/html\n\n";
print "
Results";
print "...results...
";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#create an array of pairs
@pairs = split(/&/, $buffer);
#split each pair into a hash
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
#translate + signs back to spaces
$value =~tr/+/ /;
#convert any hex values back
$value =~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
#put it in the param hash table
$param{$name} = $value;
} # end foreach
$userName = $param{'txtName'};
print "Hi, $userName\n";
if (uc($userName) eq "WALLY"){
print "I found you at last!!!\n";
} else {
print "Sorry. I was looking for Wally.\n";
} # end if