http://qs1969.pair.com?node_id=610089

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 nntp.perl.org, cpan & google and nothing stands out as to what I am looking for.

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

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

    --shmem

    _($_=" "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}