Prints out all the environmental variables nicely.
#!/usr/local/bin/perl @degiskenler = keys %ENV; @degiskenler = sort @degiskenler; print "Content-type: text/html; charset=iso-8859-9\n\n"; print "<HTML>\n"; print "<BODY>\n"; print "<H2>Environmental Variables</H2><BR>"; print "<TABLE BORDER=1 ALIGN=MIDDLE> \n"; foreach $degisken (@degiskenler) { print "<TR> \n"; print "<TD> $degisken </TD> \n"; print "<TD> $ENV{$degisken} </TD> \n"; print "</TR> \n"; } print "</TABLE>"; print "</BODY>"; print "</HTML>"

Replies are listed 'Best First'.
RE: Environmental Variables
by athomason (Curate) on Aug 27, 2000 at 12:57 UTC
    Or:
    #!/usr/bin/perl -w use strict; use CGI ":standard"; print header, start_html('CGI Environment Dump'), h2('CGI Environment Dump'), table({-border=>1}, Tr([map td(["$_", "$ENV{$_}"]), sort keys %ENV])), end_html;
      Neither of these fix problems with less-thans or greater-thans or ampersands in the environment (not "environmental") variables. So, either dump them as text/plain:
      #!/bin/sh echo content-type: text/plain echo printenv
      Or escape them properly:
      #!/usr/bin/perl use CGI ":all"; use HTML::Entities; print header, start_html("env"), h1("env"), # can't have h2 without h1, c'mon! table({-border => 1}, Tr([map td([map encode_entities($_), $_, $ENV{$_}]), sort keys %ENV])), end_html;

      -- Randal L. Schwartz, Perl hacker