Whoa, careful with that advice:
print $ENV{PWD}, "\n";
chdir('perl');
print $ENV{PWD}, "\n";
print `ls`;
Yeah, I wouldn't normally use the backticks there, but it proves my point. Also, $0 is spoofable. Cwd is a more reliable solution.
Update: You can spoof $0 by using symlinks, at least if your OS supports them. | [reply] [d/l] |
Unlike argv[0] in C, $0 in Perl is not spoofable. See FindBin is broken (RE: How do I get the full path to the script executing?) for more details.
But $0 is certainly inappropriate for getting the full path to "the current working directory" or "where the script was called from" (though I could see misinterpretting this last phrase to mean the full path to the script). $0 often tells you the full path to where the script resides.
-
tye
(but my friends call me "Tye")
| [reply] [d/l] |