#!/usr/bin/perl -w
use strict;

# Why are you using this?  You should be using CGI.pm

my (%input) = &parse_stdin();
my ($echo) = join('', map { qq[<div>$_ = $input{ $_ }</div>] } keys %input);

print <<__OUTPUT__;
Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en">
   <head>
      <title>Output</title>
      <meta
       http-equiv="Content-Type"
       content="text/html; charset=iso-8859-1" />
   </head>
   <body>
      <h1>You should be using CGI.pm!</h1>
      <h2>Output</h2>
      <div>
         $echo
      </div>
      <p>&#160;</p>
   </body>
</html>
__OUTPUT__

sub parse_stdin {
   my ($i) = 0; my ($buffer) = ''; my (%params) = ();
   if ($ENV{'REQUEST_METHOD'} || '' eq 'GET') { $buffer = $ENV{'QUERY_STRING'} }
   else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'} || 0) }
   foreach (split (/[&;]/, $buffer)) {
      my ($key, $content) = split (/=/, $_);
      $content =~ tr/+/ /; $content =~ s/%(..)/pack("c",hex($1))/ge;
      $params{ $key } = $content;
   } %params
}