in reply to DOS's %0\..\ Perl Equivalent

Do you wish to get the directory in which a script is being executed FROM regardless of what the current working directory? If so, then $0 may be your savior.

if ($0=~/^(.+)\/.*/) { $dir=$1; } else { $dir="."; }

I'm sure there is a File::* module that will return the path (opposite of Basename), but it's real easy to roll your own. Of course this method doesn't account for Windows reverse directory seperators; but I'll leave that implementation as a exercise to the reader.

Replies are listed 'Best First'.
Re: Re: DOS's %0\..\ Perl Equivalent
by chipmunk (Parson) on Jan 19, 2001 at 23:38 UTC
    I guess the opposite of File::Basename is File::Basename? In addition to the basename() method, the module includes dirname() for getting the directory path and fileparse() for getting all the pieces of a path at once.