Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

<update2> Sorry, I got so caught up in the point I was trying to make - that Perl scans the shebang line even when running the script as perl test.pl - that I missed the limitation that the AM pointed out below, that you are right that #!/usr/bin/env perl -w does in fact not work when invoking the script via ./test.pl. </update2>

so that #!/usr/bin/env perl -w does not work

It does for me:

$ cat test.pl #!/usr/bin/env perl -wls print $x+undef; $ perl test.pl -x=5 Use of uninitialized value in addition (+) at test.pl line 2. 5

From perlrun: 'The #! line is always examined for switches as the line is being parsed. ... Parsing of the #! switches starts wherever "perl" is mentioned in the line.'

(I'm not sure about the history of this feature at the moment.) Update: The description of this feature was in perl-5.000, although apparently the support for which options are supported there has changed, for example perl58delta says "The command-line options -s and -F are now recognized on the shebang (#!) line." or perl5100delta says "The -C option can no longer be used on the #! line." (Although as choroba pointed out and as the docs say: "It wasn't working there anyway, since the standard streams are already set up at this point in the execution of the perl interpreter.")


In reply to Re^3: How do I use 'which' in the hash-bang line? (updated x2) by haukex
in thread How do I use 'which' in the hash-bang line? by rje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.