Sometimes you get more power from UNIX than you expect, as Tanktalus suggests. The shell can be your best friend, but it can obtusely bite you as well. Programs can be written for many interpreters (including many shells and languages), and you mostly do not want to be required to call the interpreter first; you want to 'execute' the file directly. The two bytes \x23\x21 are called the 'magic number' that signifies that the rest of that line is a path to the proper interpreter when they are the first two bytes of the file. However, a direct command line input is interpreted as though it is "$quoted", but the #! line is not. If the interpreter (perl) is already handling the file, the #! looks like a comment.

There are many reasons why #! exists. You might wish to use a statically-compiled version of a language, or a 64-bit version, for some things and not for others.

Ah, the power of source code: You could even compile a Perl that reads the #! and replaces itself with the interpreter specified there! :D

In reply to Re: #! -- why doth thou exist? by samizdat
in thread #! -- why doth thou exist? by punkish

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.