in reply to How do I get the full path to the script executing?

Do it like that:

#!/usr/bin/perl -w use strict; use File::Spec::Functions qw(rel2abs); print rel2abs($0);

Originally posted as a Categorized Answer.

Replies are listed 'Best First'.
Re: Re: How do I get the full path to the script executing?
by clemburg (Curate) on Nov 08, 2000 at 21:22 UTC

    If you want only the directory part, use File::Basename, like this:

    #!/usr/bin/perl -w use strict; use File::Spec::Functions qw(rel2abs); use File::Basename; print dirname(rel2abs($0));

    Using a regex here is calling for trouble.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com