I can run perl scripts on certain computers with this first line:
#!/usr/bin/perl
However on other computers this does not work.
AFAIK this line represent the location of the perl interpreter.
How can I find out the correct path to the perl interpreter resp. which
path I have to enter in the first line ?
Common practice is to use the following hashbang instead:
#!/usr/bin/env perl
or
#!/usr/bin/env perl -options
The utility env(1)'s purpose is ostensibly to run programs with
certain specified environment variable bindings, which are passed to
env as name=value pairs preceding the name of the command to run;
but when used this way, it simply execs the first copy of "perl"
that it finds on the path, passing it any options specified
thereafter.
On almost all modern, Unix-like (including Linux, *BSD, and OS X)
systems, env is either installed at /usr/bin/env or has a symbolic
link to it from that path. On older versions of Caldera OpenServer,
however, and maybe a couple other now-obscure operating systems,
there's only /bin/env; but the existence of /usr/bin/env is
widespread enough these days to make it an extremely portable (and
popular) choice.
On the Unix systems I regularly use, anyway (OpenBSD, OS X, and
Debian Linux), the hashbang has to specify a *full* interpreter
path, which is the reason why the name "perl" cannot simply be put
in there without proxying it through an absolutely-referenced
command in this manner.