By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,693 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,693 IT Pros & Developers. It's quick & easy.

appending to PATH

P: 2
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.
Sep 23 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 3,503
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:

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


Sep 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.