On 5/26/05, Peter Rabbitson <[EMAIL PROTECTED]> wrote:
> Is this:
> 
> my $path = [File::Spec->splitpath (File::Spec->rel2abs ($0))]->[1];
> 
> the only OS independent (unix/win32) way to determine the absolute path of
> the directory which contains the current process, or there is a less cryptic
> way that I am overlooking?
> 

What do you mean by "current process"?
If you mean "the path to the currently running executable" ($0), You
can use a combination of the abs_path function from Cwd together with
"dirname" from File::Basename :
use Cwd qw(abs_path);
use File::Basename qw(dirname);
my $path = dirname(abs_path($0));

However please note that the current process may be running in an
entirely different directory then the one that hold the executable. To
find the current directory, use:
use Cwd qw(cwd);
my $path = cwd();

HTH,
-- 
Offer Kaye

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to