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

Is it possible to print all of the values stored in $ENV

$ENV{'REMOTE_ADDR'};
$ENV{'HTTP_REFERER'};
etc.

I need to find out all of the values that are being sent to my script,

Thanks You.

Replies are listed 'Best First'.
Re: diplaying the entire $ENV set
by KM (Priest) on Sep 05, 2002 at 12:57 UTC
    print qq{$_ => $ENV{$_}\n} for sort keys %ENV;
    Make the \n a <br> if used in CGI.

    Cheers,
    KM

Re: diplaying the entire $ENV set
by kelan (Deacon) on Sep 05, 2002 at 13:18 UTC
      Heh, nice approach ;)
Re: diplaying the entire $ENV set
by barrd (Canon) on Sep 05, 2002 at 13:01 UTC
    Simple:
    #!/usr/bin/perl use strict; use warnings; print "Content-type: text/html\n\n"; foreach my $k (sort (keys %ENV)) { print "$k: $ENV{$k}<BR>"; }
    HTH
Re: diplaying the entire $ENV set
by count0 (Friar) on Sep 05, 2002 at 13:07 UTC
    In case it's not clear from the examples above, I'd simply like to point out that $ENV{SOMTHING} is accessing a value from Perl's predefined %ENV hash.

    For a list of all predefined variables, see perlvar.
Re: diplaying the entire $ENV set
by Anonymous Monk on Sep 05, 2002 at 14:38 UTC
    from a book I have:

    #!/usr/bin/perl5 print "Context-type: text/plain\n\n"; while ( ($key,$value) = each %ENV ) { print "[$key]\t[$value]\n"; } exit 0;