in reply to Re: URL $ENV variables
in thread URL $ENV variables

I tried that but couldn't figure it out. there is no reference as to which $ENV variables there are in perl.

Replies are listed 'Best First'.
Re: Re: Re: URL $ENV variables
by antirice (Priest) on Aug 04, 2003 at 08:45 UTC

    Check out this script for what environment variables are set. It's nice for debugging, but don't keep it on your server.

    #!/usr/bin/perl -w use CGI qw(header start_html end_html); print header(),start_html(); print "$_ = $ENV{$_}<br>" foreach (keys %ENV); print "\$0 is $0"; print end_html();

    Of course, you could just use CGI and use its url() or script_name() methods. For more on the syntax for the url() method, check out this link.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

      Or simply:
      #!/bin/sh
      env
      
Re: Re: Re: URL $ENV variables
by Anonymous Monk on Aug 04, 2003 at 22:35 UTC
    That's because $ENV is decided by the enviornment the script is running in. See antirice's post above this. Note that $ENV is different depending upon your server OS, and whatever else happens to be floating around on the system. Also note that there is a lot more stuff in $ENV when running a script on a webserver, then just running it on the command line. Printing all the keys in the enviornment you will use is basically the only way to be sure you know what's available.