#!/client/bin/perl

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


if ($ENV{'REQUEST_METHOD'} eq 'GET') {
  $in = $ENV{'QUERY_STRING'};
  print "METHOD: GET<br>\n";
}
else {
  read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
  print "METHOD:POST<br>\n";
}

@pairs = split(/&/, $in);
foreach $pair (@pairs) {
  $pair =~ tr/+/ /;
  $pair =~ s/%(..)/pack("c",hex($1))/ge;

  $pos = index($pair,"=");

  $entry{substr($pair,0,$pos)} = substr($pair,$pos+1);
}

foreach (keys %entry) {
  print "<em>$_</em> = $entry{$_}<br>\n";
}