Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

list of all the $env variables

by Anonymous Monk
on May 08, 2004 at 19:45 UTC ( [id://351746]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can someone link me to a node or some URL that shows you all the $env variables we have to play with?

thanks everyone

Replies are listed 'Best First'.
Re: list of all the $env variables
by biosysadmin (Deacon) on May 08, 2004 at 19:54 UTC
    As merlyn said, all of your environment variables are stored in the %ENV hash. To list them, just iterate over the members of a hash. Here's how I would do it:
    print "List of all environment variables:\n"; while ( my($env_name,$env_value) = each %ENV ) { print "\t$env_name = $env_value\n"; }
•Re: list of all the $env variables
by merlyn (Sage) on May 08, 2004 at 19:50 UTC
    There's only one $env variable, and it starts out undeclared.

    Perhaps you mean %ENV? In which case, a simple loop will dump them, or just go into the debugger and enter x \%ENV.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: list of all the $env variables
by eXile (Priest) on May 08, 2004 at 20:06 UTC
    If your question is targeted to CGI-programming you might find the ubiquitous env.pl script useful:
    #!/bin/perl print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<TITLE>Server-provided Environment variables</TITLE>"; print "<BODY>\n"; print "<TABLE>\n"; print "<TR><TD colspan=2 align=center>Environment Variables</TD></TR>\ +n"; foreach my $x (keys %ENV) { print "<TR><TD>$x</TD><TD>$ENV{$x}</TD></TR>\n"; } print "</TABLE></BODY></HTML>\n";
    Put it in your cgi-bin (if it's not already there, I think it comes default with apache). Be sure it is executable by the user the webserver runs as. Otherwise google for an active env.pl on somebody elses webserver.
        Being really lazy (being a virtue, yada yada), I just cut-and-paste the first env.pl I found googling. I agree doing this text/plain is way better.
Re: list of all the $env variables
by b10m (Vicar) on May 08, 2004 at 20:05 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-19 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found