#!/usr/local/bin/perl
my $query_string = "";
#Get the input
if ($ENV{REQUEST_METHOD} eq 'POST') {
read(STDIN, $query_string, $ENV{CONTENT_LENGTH});
} else {
$query_string = $ENV{QUERY_STRING};
}
##### We will remove this
print "Content-Type: text/html\n\n";
print "Query String is \n
$query_string";
##### We will remove this
# Split the name-value pairs
@pairs = split(/&/, $query_string);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
#Converting Hex to English.
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$FORM{$name} = $value;
}
@thanks = split (/ /, $FORM{'comments'});
foreach $thank (@thanks){
$FORM{$thank} = $thank;
}
#Give output
print <
Guest book Result
Guest book Results
Comments : $FORM{'comments'}
Words: $FORM{$thank}
END