At Tue, 30 Mar 2004 13:47:12 +1000, Mary Gardiner wrote:
> I'm accustomed to starting my various Python and Perl files with:
> #!/usr/bin/env python
> or
> #!/usr/bin/env perl
> However, you can't pass arguments to whatever you're invoking, thanks to
> the limits of the #! interpretion ("#!/usr/bin/env perl -w" at the top
> of a file causes a search for a binary named "perl -w"). What workaround
> do people use for this problem in general? (I know -w is equivalent to
> "use warnings;" so I know the Perl workaround)
#!perl -w
works on Linux, I'm not sure how it goes on other Unices..
For the perl case, you can use some wacky perl features (see
perlrun(1)). These all assume /bin/sh exists and use that to find
perl in $PATH:
#!/bin/sh
exec perl -x
#!perl -w
A variant on the standard MakeMaker-produced perl script:
#!/bin/sh
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
or even:
#!/bin/sh -- # -*- perl -*- -w
eval 'exec perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
--
- Gus
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html