in reply to Clarify My doubt on #!/usr/local/bin/perl

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.

Replies are listed 'Best First'.
Re^2: Clarify My doubt on #!/usr/local/bin/perl
by ysth (Canon) on Jun 01, 2005 at 05:43 UTC
    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.
    Most multisyllabic character names get shortened in various ways. According to the jargon file, "bang" originated at CMU.
[OT] Re^2: Clarify My doubt on #!/usr/local/bin/perl
by fokat (Deacon) on Sep 20, 2005 at 14:25 UTC

    Dear monarch

    (...)I don't know why it is called bang.. I thought it was an exclamation mark myself(...)

    A few years back, email and news were sent from server to server using a protocol (and program) called UUCP (Unix-to-Unix-CoPy). This used phone lines to push packets of text files from machines that for the most part, were "connected" to the network intermitently, a few times a day.

    In those days, email addresses had to include the routing information, telling each system how to forward your message. An email address could have been something like ucbarpa!dino!usb!lem (If memory serves well). Each word in the address would be a host/system/site identifier, as known by the corresponding node. The ! would then instruct said node to "bang" or bounce the file to the next system in line.

    As you may easily guess, this system was very awkward (sp?) to use. Later it was entirely replaced with SMTP and NNTP for direct transmission of email and Usenet news from server to server, using the Internet as transport.

    During that transition, things were complex because provisions had to be made for rewriting the addresses to RFC-822 format (ie user@site) and for combining RFC-822 and UUCP in the same address, to deal with hybrid or incomplete connections (ie usb!lem@dino.conicit.ve). To this respect, Internet is so much simpler now.

    Google for UUCP for more information.

    Best regards

    -lem, but some call me fokat