Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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

by Fastolfe (Vicar)
on Dec 16, 2000 at 23:42 UTC ( #47065=categorized answer: print w/replies, xml ) Need Help??

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

Since you put this in the CGI section, I'm assuming that by Perl script you mean CGI script. Web servers typically run these out of your cgi-bin directory, using that directory as the script's current working directory. Unfortunately your question is a bit vague. Do you mean the script's current working directory, or where the script physically resides on the filesystem?

If it's the former, use the Cwd module for a portable way to do this. If it's the latter, this isn't really a CGI issue and is already discussed elsewhere. See: How do I get the full path to the script executing? The only catch is that this information can be faked or made unreliable, but it's usually OK so long as you're not relying on it as a security mechanism.

  • Comment on Answer: How do I find what dir the perl script is running from?
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2016-10-25 04:27 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.