What deternines the return from Perl $ENV{PATH} ?
I get about 10 paths, one or more from each of 5 partitioins (out of 12), only 2 of which have anything to do with Perl.
|
|
|||
Perl $ENV{PATH} Returns
What deternines the return from Perl $ENV{PATH} ?
I get about 10 paths, one or more from each of 5 partitioins (out of 12), only 2 of which have anything to do with Perl. 1 Reply
%ENV is a hash in Perl that is populated with all the environment variables at the time your program is run. When you execute the following statement:
$path=$ENV{'PATH'};
You are setting the contents of $path with PATH variable. Whatever is in the PATH variable is copied to $path. If you display, I do this in the debugger, the contents of the %ENV hash you will get something like this: DB<3> x %ENV 0 'HOME' 1 '/Users/joesmoe' 2 'DISPLAY' 3 '/tmp/launch-RP8ISv/org.x:0' 4 'COMMAND_MODE' 5 'unix2003' 6 'VERSIONER_PERL_PREFER_32_BIT' 7 'no' 8 'SSH_AUTH_SOCK' 9 '/tmp/launch-fFMjWc/Listeners' 10 'Apple_PubSub_Socket_Render' 11 '/tmp/launch-QdBg9r/Render' 12 'PWD' 13 '/Users/joesmoe/Downloads' 14 'LANG' 15 'en_US.UTF-8' 16 'USER' 17 'joesmoe' 18 'LOGNAME' 19 'joesmoe' 20 '__CF_USER_TEXT_ENCODING' 21 '0x401:0:0' 22 'TERM_PROGRAM' 23 'Apple_Terminal' 24 'SHLVL' 25 1 26 'PERLDB_PIDS' 27 5290 28 '_' 29 '/usr/bin/perl' 30 'TERM_PROGRAM_VERSION' 31 299 32 'TERM_SESSION_ID' 33 '804D189B-C286-4CC6-8945-AB66A071EC5F' 34 'PATH' 35 '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin' 36 'SHELL' 37 '/bin/bash' 38 'TMPDIR' 39 '/var/folders/x1/cpn04brn7l3fyf3rgr75vbhw000101/T/' 40 'TERM' 41 'xterm-256color' 42 'VERSIONER_PERL_VERSION' 43 5.12 DB<4> You can see that every EVEN number line is the variable name and the following ODD number line is the contents. So when you specifically ask for 'PATH' it parses this hash, finds PATH, and then gives you the value in the following line. In my case here it would return the contents of line #35. That's the basic gist of how that works. CR
=========================
Sent to you from my iPad, iPhone, BlackBerry, Laptop, Desktop, or Kitchen Toaster |
|||
|