Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Full path to the current file?

by cLive ;-) (Parson)
on Jan 08, 2008 at 16:11 UTC ( #661119=note: print w/ replies, xml ) Need Help??


in reply to Full path to the current file?

I have a feeling the proposed solutions above don't give you the path relative to the module, but to the script. Cwd is the simplest solution though:

#!/usr/bin/perl use strict; use warnings; use Cwd qw(abs_path getcwd); print "This script is: ".abs_path($0)."\n"; print "Working dir is: ".getcwd()."\n";

but that won't tell you the path from the actual module.

For that, you'll need to hard code the path to the module (I think):

my $abs_filepath = abs_path("$module_dir/$relative_pilepath");
__FILENAME__ is your friend...


Comment on Re: Full path to the current file?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-07-29 02:24 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 (260 votes), past polls