#!/usr/local/bin/perl # Script to output CGI Information # Output the MIME headers and HTML document head print("Content-Type: text/html\n\n"); print("CGI Information Received\n"); print("

CGI Information Received

\n"); # Output the values of environment variables print("

Environment Variables

\n
\n"); foreach $var ("GATEWAY_INTERFACE", "REQUEST_METHOD", "CONTENT_TYPE", "CONTENT_LENGTH", "SCRIPT_NAME", "PATH_INFO", "PATH_TRANSLATED", "QUERY_STRING", "REMOTE_HOST", "REMOTE_ADDR", "REMOTE_USER", "REMOTE_IDENT", "SERVER_NAME", "SERVER_PORT", "SERVER_SOFTWARE", "SERVER_PROTOCOL", "AUTH_TYPE", "PATH") { print("
$var
$ENV{$var}\n") if $ENV{$var}; } foreach $var (sort keys %ENV) { print("
$var
$ENV{$var}\n") if $var =~ /^HTTP_/; } print("
\n"); # Output any command line arguments if ($#ARGV > 0) { print("

Command Line Arguments

\n"); foreach $i (1 .. $#ARGV) { printf("ARGv[$i]: %s
\n", $ARGV[$i]); } } # Output any data on the standard input stream if ($ENV{CONTENT_LENGTH} ne "") { read(STDIN, $content, $ENV{CONTENT_LENGTH}); print("

Data on Standard Input

\n"); print("
$content
\n"); } print("");