At 20:25 +0000 3/10/09, John Delacour wrote:
At 21:10 -0600 9/3/09, Doug McNutt wrote:
At 22:24 -0400 3/9/09, Chris Devers wrote:
How can a Perl script reliably, portably resolve the path inside which
it is running?...
$0 That's a zero. Has always worked for me to produce a full path
to a running perl script.
...There is a module "cwd"...
or rather Cwd. $0 will give the name but not the full path, so I'd suggest
the following:
#usr/bin/perl
use Cwd;
my $currentdir = cwd();
print "$currentdir/$0\n";
Interesting. It turns out that I rarely call a stored perl script
without specifying a full path in the call. I'm getting a full path
in $0 when I do that. There may be more to think about. The stuff I
just checked calls the script itself which has been made executable
rather than making a call to perl with the argument being the path to
the script. I also don't know about a stored script placed in a
directory that's included in $PATH but is not in $PWD.
"portable" seems to be the key here. Modules good for that.
--
-> Stocks are getting pilloreid <-