Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Perl Script, Know Thyself?

by brusimm (Pilgrim)
on Apr 14, 2007 at 17:48 UTC ( #610089=perlquestion: print w/ replies, xml ) Need Help??
brusimm has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks:

I have users that wish to use a script that can determine it's own location after they have copied the original script to some location of their choice. I'm assuming they want to report the location of the script to some form of output. The users are being vague about this.

Is there a function or script technique to affect this result? I've looked around on, cpan & google and nothing stands out as to what I am looking for.

Any guidance / help would be appreciated. Thank you everyone.

Comment on Perl Script, Know Thyself?
Replies are listed 'Best First'.
Re: Perl Script, Know Thyself?
by jdporter (Canon) on Apr 14, 2007 at 17:57 UTC
Re: Perl Script, Know Thyself?
by shmem (Canon) on Apr 14, 2007 at 18:53 UTC
    You could...
    use Cwd qw(abs_path); my $location = abs_path($0); print "Location: $location\n";


    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://610089]
Approved by GrandFather
Front-paged by bingos
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2015-10-09 05:13 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (233 votes), past polls