The #! combination of characters is known as the "hash-bang". I don't know why it is called bang.. I thought it was an exclamation mark myself, but I suspect an American thought it would be cute to give that character a shorter name.

The #! characters are interpreted by linux/unix shells to mean "run whatever program follows, then pass the text on all subsequent lines to that program". It's a simple way of constructing scripts in any language, merely by defining which interpreter should be used on the first line of the script.

As the previous poster attests, you don't need it in windows. That's because windows is different to linux in that it determines which program to run your file by the file extension (in most cases this will be .pl on your system). Alternatively you can run your perl scripts by typing "perl <filename>".

There is one situation where you must provide the "hash-bang" on scripts in windows - this is in Apache for Win32, when executing perl CGI scripts. Apparently Apache looks for which interpreter to use based on the first line of any CGI scripts.


In reply to Re: Clarify My doubt on #!/usr/local/bin/perl by monarch
in thread Clarify My doubt on #!/usr/local/bin/perl by kprasanna_79

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.