in reply to Re^4: What script is this, and where is it? (Re: who am I?)
in thread who am I?
Just use $0 (or File::ScriptName::myname) to find the real script name or use File::ScriptName::mybase and File::ScriptName::mydir for whatever purposes you want; traverses all symlinks and stuff... is it enough??package File::ScriptName; use strict; use warnings; use version; our $VERSION = qv('0.1'); our $AUTHORITY = 'MASSA'; use Exporter q(import); our @EXPORT_OK = qw(myname mybase mydir); use Carp; use Cwd qw(realpath); use File::Spec::Functions qw(rel2abs); use File::Basename qw(basename dirname); BEGIN { my $myname = $0 = realpath rel2abs $0; my $mybase = basename $0, qw(.t .pm .pl .perl); my $mydir = dirname $0; croak 'chdir() used too early' unless -f $0; sub myname { $myname } sub mybase { $mybase } sub mydir { $mydir } } 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: What script is this, and where is it? (Re: who am I?)
by ikegami (Patriarch) on Sep 25, 2008 at 01:02 UTC | |
|
Re^6: What script is this, and where is it? (Re: who am I?)
by repellent (Priest) on Sep 25, 2008 at 02:55 UTC | |
|
Re^6: What script is this, and where is it? (Re: who am I?)
by TGI (Parson) on Oct 01, 2008 at 21:53 UTC |