#!/usr/bin/perl -Tw
#
#NAME
#  ae.cgi - CGI sanity test
#
#SYNOPSIS
#  http://host.dom.ain:port/CGI/ae.cgi/path/info?some&args=values...
#
#DESCRIPTION
#  This is a CGI script that returns a web page showing all its  args
#  and environment variables.
#
#  It is really a prototype CGI script, useful as  a  starting  point
#  for  writing  other  scripts.   It is also useful on its own, as a
#  quick way of learning what a particular browser is  sending  to  a
#  server.
#
#OPTIONS
#
#FILES
#
#BUGS
#
#SEE ALSO
#
#AUTHOR John Chambers <jc@trillian.mit.edu>

$| = 1;
use strict;
my($e, $n, @names, $query, $v, @vals);

use CGI;
use CGI::Carp 'fatalsToBrowser';
use diagnostics;

print "Content-type: text/html\n\n";
print "<html><head><title>Test CGI $0</title></head>\n";
print "<body><center>Test CGI $0</center>\n";
print "This is what your browser sent to this web server.\n";

print "<hr>\n";
print "Form elements:\n";
$query = new CGI;
@names = $query->param();
print "<dl compact>\n";
for $n (sort @names) {
	if (@vals = $query->param($n)) {
		for $v (@vals) {print "<dt>$n<dd>\"$v\"\n"}
	} elsif ($v = $query->param($n)) {
		print "<dt>$n<dd>\"$v\"\n";
	} else {
		print "<dt>$n<dd>(NO VALUE)\n";
	}
}
print "</dl>\n";

print "<hr>\n";
print "Environment variables:\n";
print "<dl>\n";
for $e (sort keys %ENV) {
	$v = $ENV{$e};
	print "<dt>$e<dd>$v\n";
}
print "</dl>\n";

print "<hr></body></html>\n";
