You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Wilfredo Sanchez <ws...@apple.com> on 1998/06/26 06:05:36 UTC
[PATCH] (Take II) CGI Tweak
Here's a fancier printenv script; displays environment in a simple table. It's a little friendlier to look at.
-Fred
Apple Computer, Core Operating Systems Group
wsanchez@apple.com, 408.974-5174
2 Infinite Loop 302-4K, Cupertino, CA 95014
#!/usr/bin/perl -T
##
# Show CGI Process Environment
# Wilfredo Sanchez | wsanchez@apple.com
# Apple Computer, Inc.
# Wed Oct 15 13:55:32 PDT 1997
##
# This perl program shows you how to access the process environment
# for CGI programs on your web server.
# It is also a useful debugging tool, as it shows you all of the
# available environment variables.
##
# CGI programs must print their own HTTP response headers
print "Content-type: text/html\n";
print "\n";
# Declare the SGML application as HTML 3.2
print "<!doctype html public \"-//W3C/DTD HTML 4.0/EN\">\n";
# Begin HTML
print "<html>\n";
# A minimal document must include a header region with a title
print "<head>\n";
print "<link rev=\"made\" href=\"mailto:wsanchez\@apple.com\">"; # Author
print "<title>CGI Test</title>\n";
print "</head>\n";
print "\n";
# Start document body
print "<body>\n";
print "\n";
# Put values in a table to readability
print "<table border>\n";
print "\n";
# Caption the able
print " <caption>CGI Environment</caption>\n";
print "\n";
# Include table headers
print " <tr>\n";
print " <th align=\"right\">\n";
print " Variable\n";
print " </th>\n";
print " <th>\n";
print " Value\n";
print " </th>\n";
print " </tr>\n";
# Print each key/value pair as two column in a row
foreach $key (keys %ENV)
{
print "\n";
print " <tr>\n";
print " <td align=\"right\">\n";
print " $key\n";
print " </td>\n";
print " <td>\n";
print " $ENV{$key}\n";
print " </td>\n";
print " </tr>\n";
}
print "\n";
# End table
print "</table>\n";
print "\n";
# End document body
print "</body>\n";
# End HTML
print "</html>\n";