Not stupid, just not necessarily Perl. The shebang line is a UNIX-ism.

On UNIX-en (includes Linuxen as well) when you attempt to execute any file (any file, that is, which is has its executable bit set), the shell "peeks" at the first two characters lokoing for the shebang combination, "#!". If it finds them, it reads the remainder of the line up through, but not including, the terminating newline.

It breaks apart whatever it finds into tokens, split by whitespace, and calls exec() with the first token as the command, and the remaining tokens passed as arguments (in much the same way it does with manually typed commands at the prompt), and with the current filename (i.e., '/path/whatever.pl') appended to the list of arguments.

The exec() call normally causes the current process image (i.e., the shell) to be replaced with that of the command line (say, Perl). And away we go executing whatever script you've run with the appropiate interpreter.

OK, enough background. That explains what happens when you type 'whatever.pl' at the shell prompt.

Now, for your question: If the shebang line invokes Perl on the file, it will examine the shebang line itself to pick up any options that may not have made it through the command lne passed by the original shell (some UNIX-en have an arbitrarily short limit on the number of characters they can accept on the shebang line -- occasionally as few as 32), and will then start reading/compiling the perl code, including processing requires and/or uses, as necessary.

Any shebang lines in THOSE files will not be looked at, AFAIK, (although perl may actually honor any '-w' switches in them--I forget, exactly).

Update: Apparently, Perl will try to honor any -T switches (as insofar as they have to match the taint-mode-ness of the main .pl file).

dmm

You can give a man a fish and feed him for a day ...
Or, you can
teach him to fish and feed him for a lifetime

In reply to Re: shebang line by dmmiller2k
in thread shebang line by perlmongrel

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.