Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

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

My reading of perlrun suggests that Perl's behaviour is subtle:

The #! line is always examined for switches as the line is being parsed. Thus, if you're on a machine that allows only one argument with the #! line, or worse, doesn't even recognize the #! line, you still can get consistent switch behavior regardless of how Perl was invoked...
appears to say that:

  • if you happen to be running on a system that implements the #! trick, and invoke your Perl program in a way that causes the system to use the #!, then that's fine -- you'll get as many switches and such as the system is prepared to give you.

  • however, in any event Perl will parse the #! line itself and honour switches and stuff. So, if the system doesn't do it, or you run your program by (for example) perl my_wonderful_program.pl ...., you still get the switches from the #!.

    The documentation goes on to discuss what happens if switches appear both in the command line and in the #!, and to tell you that perl needs to appear somewhere on the line for Perl to be interested in it.

So, Perl does more or less what you want. It has partly adopted the #! convention, so that even if it has no bearing on where the perl interpreter is run from, it still affects switches -- in a system independent manner.

Update: except for -T as brother Hue-Bond points out below :-(


In reply to Re: #!/usr/bin/perl vs. -*- perl -*- by gone2015
in thread #!/usr/bin/perl vs. -*- perl -*- by why_bird

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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found