Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Find the full path of the script at run time

by data64 (Chaplain)
on Mar 13, 2003 at 06:12 UTC ( [id://242599]=note: print w/replies, xml ) Need Help??


in reply to Find the full path of the script at run time

I usually use the below on ActiveState perl. Although I believe it also works on Linux.

use strict; use warnings; use English; use File::Basename qw( dirname ); use File::Spec::Functions qw( rel2abs ); my $script_dir = rel2abs( dirname( $PROGRAM_NAME ) ); print "$script_dir\n";

You could leave out the "use English" and replace $PROGRAM_NAME with $0


Update:
There is an implicit assumption in the above code, that you are not talking about a CGI script.

You should also look at How do I get the full path to the script executing?


data64

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-03-28 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found