Sign in to PrePAN

Proc::Pathname Retrieves the fully qualified path for the program



use Proc::Pathname;

my $path = Proc::Pathname::get()
        or die "failed to get pathname";


A common way to retrieve a path for the program is using the variable $0. However, sometimes it is not working for you. So, you have to find a way to retrieve the path for the program somehow differently.

The module is using system calls to do the job and written as XS module. This module was made for private purposes, mostly, for staticperl.

Ok, this was an introduction part and copy-pasted from the module documentation. Speeking freely, I have made this module because of when using staticperl I was unable to retrieve a correct value of $0 sometimes. And I suppose the module have a limited amount of purposes. I am not sure if it should be uploaded to CPAN, so let's it be here. But, who knows, may be it will be useful for you.

The name of the module was choosen as a combination of well-known system calls on Unix-like systems, more specifically, from Solaris: getexecname(). And, yep, I am not sure if the name is good.

So, if you have something to say, I will be glad to see your comments, suggestions and so on.


Actually, if used in a normal (non-staticperl) script, then the result of Proc::Pathname::get() is $^X, not $0.
Yep, you're correct. Hmm, I've read the doc "perldoc -v '$^X'" before I started working on this module. The doc says that you should not rely on this value, because of it can contains a relative path. Well, looks like I have re-invented a wheel :D
If $^X is not absolute (you can check with File::Spec->file_name_is_absolute) you can fix it with File::Spec->rel2abs.

Please sign up to post a review.