Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Environment Variable

by Anonymous Monk
on Aug 22, 2001 at 23:21 UTC ( [id://107095] : perlquestion . print w/replies, xml ) Need Help??

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

Where can I find out what environment variables I can use?
right now, i'm looking for remote IP and remote DNS
is there a site that has all of these things listed?

Replies are listed 'Best First'.
Re: Environment Variable
by cLive ;-) (Prior) on Aug 22, 2001 at 23:32 UTC
    It's server dependant - parse %ENV for complete list:
    for (keys %ENV) { print "$_ = $ENV{$_}\n"; } # eg - for remote IP, use $ENV{'REMOTE_ADDR'}
    cLive ;-)
      This is brilliant! Thanks so much!!!
      While some are server-dependant (and even request-dependant), the CGI spec requires that certain variable be set.
Re: Environment Variable
by Cine (Friar) on Aug 23, 2001 at 00:18 UTC
    There is no real limitation on what eviroment variables you can use, there are however severe limitations on which is set.

    The above code shows how to print those that are already set from perl.
    However, what do you mean by "i'm looking for remote IP and remote DNS"? If you want to find it in a CGI script, the IP is one of the variables, but you have to make a reverse DNS lookup to get the name of the ip.

    T I M T O W T D I