Re: Dumb path question

[email protected] (Doug McNutt)
Newsgroups perl.macosx
Message-ID <p05100301c5db88cf630b@[192.168.1.14]>
At 22:24 -0400 3/9/09, Chris Devers wrote, and I snipped.:
>This isn't necessarily a Mac-specific question, but I've gotten rusty
>and I'm having a brain fart here.
>
>How can a Perl script reliably, portably resolve the path inside which
>it is running? Not the PWD of the caller, mind you, but the actual
>current full path of the script itself?

$0  That's a zero.  Has always worked for me to produce a full path 
to a running perl script.

$ENV{PWD} is, as you say the working directory when perl, or the 
script as an executable with a shebang line

There is a module "cwd" I think which will keep $ENV{PWD} correct as 
you change directories around within a script..

As for portability to other than *NIX, I donno.

-- 

--> From the U S of A, the only socialist country that refuses to admit it. <--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.