[X-Unix] The which command lies?

Steve Morris barbershopsteve at gmail.com
Tue Feb 16 10:39:58 PST 2010


Eric F Crist> Not addressing the exact problem, but the one most likely to arise
>
> > next: if you are executing Perl scripts, the path of the Perl
> > interpreter is normally given in the first line.  This will override
> > the version of Perl that is in your path.
>
> Only the script is being executed directly, and not being called as an argument to the perl binary.

I'm not sure what you are trying to say here. It sounds backwards.
Scripts can't be executed directly. They are text files. Except in
very unusual cases microprocessors can't execute text files. Only the
interpreter (the perl binary) gets "executed." The shell parses the
first line of the script then launches the interpreter indicated there
with the script path as an argument, probably via fork and exec or
similar system calls. This can be confusing because perl modifies $0
(from the C argv[0]) to reflect the name of the script rather than the
name of the executable. In perl $^X is supposed to be the fully
qualified perl binary name.


More information about the X-Unix mailing list