appending to PATH

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • milica
    New Member
    • Sep 2008
    • 2

    appending to PATH

    So many web sites state that $ENV{‘PATH’} = “/newpath:$ENV{‘ PATH’}”; should append to path.

    When I include that in perl code, and echo $PATH afterwards, or just type env, there is no change in $path. ???

    Any ideas? Thanks.
    M.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    In a Perl script, the %ENV variable is actually a hash. Each variable in the hash is a key which has a value. One of those keys is "PATH", which contains the system path contents. The %ENV hash contains the CGI Envornment variables.

    To print it out, use this:

    Code:
    print "Content-type: text/html\n\n";
    print "<tt>\n";
    foreach $key (sort keys(%ENV)) {
          print "$key = $ENV{$key}<p>";
    }
    To modify the hash, I would look up a tutorial on hashes if you don't already know how.

    Regards,

    Jeff

    Comment

    Working...