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

Well, some of us have more than one perl binary on our system. e.g., a recent thread where the question was how to upgrade perl, my suggestion, echoed by wazoox, was to leave the system perl alone, and compile the desired perl into a new location. (You can read that thread to see why, but it's not relevant to this node.)

So, if you want to know which perl binary that executed your program, it could be the one in /usr/bin (the system perl), or it could be the one in /usr/local/bin (the local version). The one you find is going to be based on the PATH - does /usr/local/bin come before /usr/bin? However, the one that is actually used might be the one in the PATH (if you're running it by running "perl myscript"), or it might be the one in the shebang line, which could be either perl.

In fact, I have had multiple perls installed: /usr/bin/perl, /usr/bin/perl5.8, /usr/bin/perl5.8.7, /usr/bin/perl5.8.8, all at the same time. Your "whereis perl" would get the wrong one because I nearly always used a shebang line for #!/usr/bin/perl5.8.8. But $^X got it right. Which is good - it helped when compiling modules (perl5.8.8 Makefile.PL would result in a Makefile that used the right perl!).

  • Comment on Re^2: How to determine the path to the Perl binary that executed your program?
  • Download Code