Is there a way to get the absolute path to the Perl executable for the current process?
$ ^ X will give me the executable name Perl, but the document states that it will sometimes be a relative path, and this seems to be true for OS X, for example.
ExtUtils :: MakeMaker seems to have some kind of magic to find the absolute path, since the Makefile that it creates in my OS X contains
PERL = /usr/local/bin/perl
FULLPERL = /usr/local/bin/perl
but I have no idea how this is done or magic is easily accessible to others.
EDIT: Thanks Borodin for the tip $Config{perlpath}. Grepping for this in ExtUtils, I found this tidbit in ExtUtils :: MM_Unix :: _ fixin_replace_shebang, which I suppose uses MakeMaker to replace #! Perl with the correct shebang string.
if ($ Config {startperl} = ~ m, ^ \ #!. * / perl,) {
$ interpreter = $ Config {startperl};
$ interpreter = ~ s, ^ \ #! ,,;
}
else {
$ interpreter = $ Config {perlpath};
}
source
share