Tony Esposito wrote: > Question: > > When a Perl script - let's say myperl.pl - has the following as its > first line: > > #!/usr/bin/perl > > yet your PATH is set to use another version of Perl - let's say > /opt/perl5.6.1/bin/perl - > > then which 'Perl' is used when you execute the program from the > command line like so: > > /opt/perl5.6.1/bin/perl -e myperl.pl
(You wouldn't use -e here) This will run the script using the /opt/perl5.6.1/perl binary. The executable in the #! line is ignored. (But options on that line, like -w _are_ processed.) > > and which is used when you execute the program from the command line > like so: > > myperl.pl The kernel searches your PATH for myperl.pl. It then sees the #! line in that script and passes the script to that specific executable. > > In other words, which 'Perl' takes precedence or how does the > precedence work? Normally, you will install Perl to some location appropriate to your architecture (e.g. /usr/local/bin for BSD-ish systems) and then link /usr/bin/perl to the executable you would like to run by default. Then it is customary to use #!/usr/bin/perl in your scripts. If you want to switch your "default" version, you just adjust the link /usr/bin/perl to point to another version, and you don't need to change your scripts. It is also customary to add the perl bin directory to your PATH, so you can find the various supporting utilities that come with perl, such as perldoc. Note that when you "make install" with perl, the #! lines in the supporting utilties like perldoc will point to the specific version you are installing and _not_ to /usr/bin/perl. This makes sure that the supporting utilities run with the version of perl they were installed with. HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]