#!/usr/local/bin/perl my ($data, $i, @data, $key, $val, %FORM); if ($ENV{'REQUEST_METHOD'} eq "GET") { $data = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$data,$ENV{'CONTENT_LENGTH'}); } @data = split(/&/,$data); foreach $i (0 ..$#data) { # Convert plus's to spaces $data[$i] =~ s/\+/ /g; # Split into key and value. # splits on the first = ($key, $val) = split(/=/,$data[$i],2); # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Kill SSI command $val =~ s///g; # Associate key and value # \0 is the multiple separator $FORM{$key} .= "\0" if (defined($FORM{$key})); $FORM{$key} .= $val; } print "Content-type: text/html\n\n"; print "\n"; print "
\n"; print "\N"; print "$data
\n"; print "
\n";
foreach $key (keys %FORM) {
print "$key = $FORM{$key}
\n";
}
print "
\n";
foreach $key (sort keys %ENV) {
print "$key = $ENV{$key}
\n";
}
print "\n";
print "\n";