Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Environmental Variables

by sinan (Sexton)
on Aug 27, 2000 at 12:29 UTC ( [id://29876]=CUFP: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://29876]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-24 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found