in reply to Environmental Variables

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;

Replies are listed 'Best First'.
RE: RE: Environmental Variables
by merlyn (Sage) on Aug 27, 2000 at 15:51 UTC
    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