What does “not work under some shell” mean in Perl scripts?

In many perl scripts (especially well-known CPAN distributions), I find the following code snippet:

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell

I was wondering why this is necessary?

Thank.

+5
source share
2 answers

#!/usr/bin/perl , Perl script . , Perl , POSIX script perl(1). if 0 Perl, , eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}', .

+8

, perl. perl eval - if 0. perl eval.

+2

All Articles