[Melbourne-pm] programming tutorials: Perl

Leigh Sharpe leigh.sharpe at gmail.com
Sun Nov 14 21:58:44 PST 2010


On Mon, Nov 15, 2010 at 4:48 PM, john thornton <jdthornton at ozemail.com.au>wrote:


> The only part that confuses me is that if
>
> # is a comment
>
> then why does the shebang line have any influence:
>
> #!/usr/bin/perl
>
> or as a variant to show warnings for code
>
> #!/usr/bin/perl -w
>
>
The shebang line is treated like a comment by the perl interpreter if
invoked via
   perl yourscript.pl

But not by the OS when ivoked via
   ./yourscript.pl

On a linux system, when you invoke a script from the command line, your OS
looks for a shebang line to see what interpreter it should use for your
script. This could be perl (#!/usr/bin/perl) or bash (#!/bin/bash), or any
of hundreds of others. The -w switch is passed to the interpreter in this
case.
 The same applies for a CGI. Apache, for example, looks for a shebang line
to see which interpreter should be invoked to run your CGI. It is also
possible to write a CGI in bash and use

          #!/bin/bash

as the shebang line. Or any other interpreter for that matter.


The above doesn't apply to Windows, however.

Hope this clears it up a bit.

Leigh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20101115/e4facef3/attachment.html>


More information about the Melbourne-pm mailing list