in reply to How to determine the path to the Perl binary that executed your program?

I just confirmed on my system:
print $ENV{_};
works correctly, it will even report the soft link if used.

UPDATE:
To confirm setup a softlink (in *nix) ln -s /usr/bin/perl /usr/local/bin/perl.
then try: /usr/local/bin/perl -e 'print "$ENV{_}\n"; print "$^X\n";'
Output:

/usr/local/bin/perl /usr/bin/perl


grep
Mynd you, mønk bites Kan be pretti nasti...

Replies are listed 'Best First'.
Re^2: How to determine the path to the Perl binary that executed your program?
by Anonymous Monk on Sep 28, 2006 at 20:29 UTC
    Unfornately, $ENV{_} doesn't work on Windows. Thanks though.

      If you can ensure that perl is called with an explicit interpreter, either by fully qualifying the path or by using the Windows extension mechanism then $^X should be reliable.

      ---
      $world=~s/war/peace/g

        I'm probably misunderstanding you, but even if perl is invoked without explicit path info and is found through the path environment variable, $^X is still correctly set:

        C:\test>perl -le" print $^X" C:\Perl\bin\perl.exe C:\test>..\perl\bin\perl -le" print $^X" C:\Perl\bin\perl.exe

        The only way I know of getting a different value for the path in $^X is if it is invoked via a subst (or NET USE) drive:

        C:\test>subst p: c:\perl\bin C:\test>p:perl -le" print $^X" P:\perl.exe

        Even then, so long as the subst remains in force, $^X remains valid for all normal uses.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: How to determine the path to the Perl binary that executed your program?
by mreece (Friar) on Sep 28, 2006 at 20:00 UTC
    neat trick, but i get undef!