matchone.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";

$phrase = $formdata{'phrase'};

if ($phrase =~ /e/) {
	print "<P>Sorry, that sentence did in fact have an e. I told you: it's harder than it seems.";
} else {
	print "<P>Congratulations, that sentence had no e. Quite a feat!";
}