Tony Esposito <[EMAIL PROTECTED]> wrote:
> So if I understand you correctly, if the line
>
> #!/usr/bin/perl
>
> exists in your Perl program, then that Perl is used regardless.
>
> And if it is missing, then
>
> perl -e myperl
>
> will use the first Perl environment that is found in the environment $PATH.
Not quite.
If you invoke perl with the script name as an argument
$ perl scriptname.pl
Then the first "perl" in your $PATH will run the script, and
the "#!" (the "shebang) is never consulted. If you don't have
perl in your $PATH then you'll get a shell error.
On the other hand, when you execute a perl script directly
$ scriptname.pl
The kernel will see the "#!/usr/bin/perl" line and invoke
/usr/bin/perl with "scriptname.pl" as an argument.
This all happens before perl starts up, and it works just
the same way for any type of shebang script (shell, awk, ruby,
what-have-you).
Now... *after* perl starts up, it will read the "#!" line and
look for command line flags.
This turns on warnings, for instance:
#!/usr/bin/perl -w
And in the oddball case where perl runs a script whose shebang
points to something other than perl, it will try exec that other
something.
e.g. if you use perl to run a shell script
~ > cat t.sh
#!/bin/sh
echo Shell!
~ > perl t.sh
Shell!
But you can't use this trick to run an alternate version of
perl (unless you rename the alternate version.) Full details
are in the "perlrun" document.
~ > perldoc perlrun
HTH
--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]