There's a potential subtle problem with using env, which is
that you typically can't pass arguments to the perl binary this way,
like for example
#!/usr/bin/env perl -w
On my Debian Linux this produces
$ ./666330.pl
/usr/bin/env: perl -w: No such file or directory
This is not a problem with env (running /usr/bin/env perl -w 666330.pl from the command line would work fine...), but rather
with many Unix kernels, which treat everything after the interpreter
specified on the shebang line (here /usr/bin/env) as a
single argument, i.e. it would pass "perl -w" to
/usr/bin/env as the program name to execute... which of course
doesn't exist. This can easily be seen with strace:
$ strace -e trace=execve ./666330.pl
execve("./666330.pl", ["./666330.pl"], [/* 24 vars */]) = 0
execve("/home/almut/bin/perl -w", ["perl -w", "./666330.pl"], [/* 24 v
+ars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/bin/perl -w", ["perl -w", "./666330.pl"], [/* 24 va
+rs */]) = -1 ENOENT (No such file or directory)
execve("/usr/bin/perl -w", ["perl -w", "./666330.pl"], [/* 24 vars */]
+) = -1 ENOENT (No such file or directory)
execve("/bin/perl -w", ["perl -w", "./666330.pl"], [/* 24 vars */]) =
+-1 ENOENT (No such file or directory)
execve("/usr/bin/X11/perl -w", ["perl -w", "./666330.pl"], [/* 24 vars
+ */]) = -1 ENOENT (No such file or directory)
/usr/bin/env: perl -w: No such file or directory
|