Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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
Re: Finding out name and path of script file
by Fletch (Chancellor) on May 26, 2004 at 23:36 UTC

    Erm, no.

    Darwin lemur.phydeaux.org 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-07-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls