Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How do I find what dir the perl script is running from?

( #48830=categorized answer: print w/ replies, xml ) Need Help??

Q&A > GUI Programming > How do I find what directory the perl script is running from? contributed by Theodorus

I use:

use FindBin qw($Bin);

$Bin is set to the value of the script's path.

Comment on Answer: How do I find what dir the perl script is running from?
Download Code
Replies are listed 'Best First'.
Re: Answer: How do I find what dir the perl script is running from?
by Anonymous Monk on Dec 30, 2000 at 00:29 UTC
    Even better (for Unix), you can try one of the following...

    $var = `/usr/bin/pwd`; # put the current dir in to $var
    

    print `/usr/bin/pwd`; # print the cwd to STDOUT

      this way you'll get dir the script is running _on_, and not the path script is running _from_
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2015-07-30 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls