From: Paul Jarc (prj@po.cwru.edu) Subject: Re: Execing perl? Newsgroups: gnu.bash.bug Date: 2001-07-11 12:11:10 PST "Paul D. Smith" writes: > The Perl docs (perlrun) say you can use this stanza to write a perl > script when you don't know where the perl runtime will be; something > like: > > #!/bin/sh -- # -*- perl -*- > eval 'exec perl -wS $0 ${1+"$@"}' > if $running_under_some_shell; > > This doesn't work if bash is /bin/sh; I get this error: > > /bin/sh: -- # -*-perl-*-: unrecognized option This will break *any* interpreter, as long as it's on Linux. Linux passes everything after the first space as a single argument to the interpreter. The eval stuff isn't what you want anyway, and I don't think it ought to be used that way in the perlrun man page. It's meant to be used like this: #!/path/to/perl eval 'exec perl -wS $0 ${1+"$@"}' if $running_under_some_shell; Then if you have something like csh that tries to interpret the script itself instead of simply passing the script name to execve, it'll still become perl. The next example in the perlrun man page is what you want: #!/usr/bin/env perl This assumes a location for env, but searches for perl in $PATH. paul