Re: Dumb path question

[email protected] (Chris Devers)
Newsgroups perl.macosx
Message-ID <[email protected]>
On Mon, Mar 9, 2009 at 10:33 PM, Chas. Owens <[email protected]> wrote:
>
> $0 holds the path to the currently executing file (including the
> filename).  Often this is a relative path, so you will want to call
> Cwd's realpath on it to get the absolute path.  Then call dirname on
> it to find the directory the script is in.  All of this is in Core
> Perl, so it should be portable to any platform Perl works on.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use File::Basename;
> use Cwd qw/realpath/;
>
> print dirname(realpath $0), "\n";

Ta, that did it.

I was forgetting about Cwd, now it seems to work fine.

Thanks!


-- 
Chris Devers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.