Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: different exe path for different OS

by DrHyde (Prior)
on Sep 01, 2010 at 07:43 UTC ( [id://858296] : note . print w/replies, xml ) Need Help??


in reply to different exe path for different OS

Given that you're using a package management system (because to not do so would be crazy!) then can't whatever you use to create the packages for the two platforms re-write the #! line for you?
  • Comment on Re: different exe path for different OS

Replies are listed 'Best First'.
Re^2: different exe path for different OS
by bergbrains (Acolyte) on Sep 01, 2010 at 14:38 UTC
    At least in our case, our scripts are shared via NFS across multiple platforms, so that doesn't make sense, because the requirement is that the exact same script must execute with the platform-specific interpreter when run on different platforms.

      In that case, Brother Salva's answer is the one you want. In this case, using $^X will work, but in general it's good practice to use Config; and then use $Config{perlpath} instead. $^X can sometimes get confused if your original script is invoked with a relative path to perl (eg as ../myperl/bin/perl foo.pl) and then does a chdir before you try to execute $^X, and on some more exotic platforms.

      Strictly speaking, you should also pay attention to $Config{exe_ext} as well, sticking it on the end of $Config{perlpath} if it's not already there, but given that you're only on Unix you don't need to care about that.