Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Finding out name and path of script file

by crenz (Priest)
on May 26, 2004 at 23:30 UTC ( #356755=perlquestion: print w/ replies, xml ) Need Help??
crenz has asked for the wisdom of the Perl Monks concerning the following question:

This sounds like a trivial question, but somehow I can't find the answer. I'd like to be able to find out the location of the script file that is being executed by perl. $0 won't do, because it doesn't contain the path. Cwd won't do, because on Mac OS X, the operating system sets the current working directory to /.

Can anyone help me out?

Comment on Finding out name and path of script file
Select or Download Code
Replies are listed 'Best First'.
Re: Finding out name and path of script file
by Fletch (Chancellor) on May 26, 2004 at 23:36 UTC

    Erm, no.

    Darwin 7.3.0 Darwin Kernel Version 7.3.0: Fri Mar +5 14:22:55 PST 2004; root:xnu/xnu-517.3.15.obj~4/RELEASE_PPC Power M +acintosh powerpc lemur:~ 604> ( cd /tmp ; perl -MCwd -le 'print getcwd' ) /private/tmp

    Perhaps if you included more details about how you're running it (and see the FindBin module).

      Thanks for your fast reply, Fletch. I knew there must be something, but couldn't find anywhere. FindBin does what I mean. Perfect, thanks!

      As for changing the path, I should have included more context, sorry. I was talking of running GUI applications in Mac OS X ".app" format (and using a perl script as the executable), and not of standalone scripts, of course.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://356755]
Approved by kvale
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-11-27 14:19 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls