#!c:/perl/bin/perl
 
# cgienv.pl
#
# A Perl program to list some of the common CGI environment variables.
# Coincidentally, we cover associative arrays and the each() function
# here, too.
 
    require "perl-cgi/html.pl";        # Call in HTML header, ender.
 
# Fill an associative array with the variable names and
# short descriptions.
 
    %EnvVarList =
        (
        'AUTH_TYPE',            'Server\'s authentication method is: ',
        'CONTENT_LENGTH',       'Length of any attached information: ',
        'CONTENT_TYPE',         'Type of any attached information: ',
        'GATEWAY_INTERFACE',    'CGI version on server is: ',
        'HTTP_ACCEPT',          'Client will accept these MIME types: ',
        'HTTP_REFERER',         'Referrer\'s URL is: ',
        'HTTP_USER_AGENT',      'Client\'s browser is: ',
        'PATH_INFO',            'Extra PATH information is: ',
        'PATH_TRANSLATED',      'PATH translation is: ',
        'QUERY_STRING',         'Query string sent by client is: ',
        'REMOTE_ADDR',          'Client\'s IP address is: ',
        'REMOTE_HOST',          'Client\'s domain name is: ',
        'REMOTE_IDENT',         'Identity data sent by client is: ',
        'REMOTE_USER',          'User ID sent by client is: ',
        'REQUEST_METHOD',       'Client\'s request method is: ',
        'SCRIPT_NAME',          'URL of the CGI application is: ',
        'SERVER_NAME',          'Server\'s computer name is: ',
        'SERVER_PORT',          'Connection made at this port: ',
        'SERVER_PROTOCOL',      'Server is using this protocol: ',
        'SERVER_SOFTWARE',      'Server is running this software: '
        );
 
# Start up an HTML document, then run the variables out to
# it with their descriptions.
 
    &HTML_Header ("Common CGI environment variables");
 
    print "<BODY>", "\n";
    print "<H1>Some of the common CGI environment variables</H1>", "\n";
    print "<H3><I>Note:  Some variables have no value. ";
    print "These will be blank.</I></H3>", "\n";
    print "<HR>", "\n";                        # Draw a rule.

    while (($EnvironVar, $Desc) = each (%EnvVarList))
        {
        print $EnvironVar, ": ", $Desc, $ENV{$EnvironVar}, "<BR>", "\n";
        }
 
# Ship the HTML ender.  We're done.
 
    &HTML_Footer;
 
#                    End cgienv.pl
