echo.cgi

#!/usr/local/bin/perl
use strict;
use HTML::Template;

my $tmpl = HTML::Template->new( filename => "echo.tmpl" );

my $query;
if ($ENV{'REQUEST_METHOD'} eq "POST") {
  $query = join "", <STDIN>;
} else {
  $query = $ENV{'QUERY_STRING'};
}

my @param;
for (split /&/, $query) {
  if (/([^=]+)=(.+)/) {
    push @param, { NAME => $1, VALUE => $2 };
  }
}
$tmpl->param( PARAM => \@param ) if (@param);

print "Content-Type: text/html\n\n", $tmpl->output();

__END__

echo.cgi J