[Melbourne-pm] programming tutorials: Perl

Daniel Pittman daniel at rimspace.net
Sun Nov 14 22:09:00 PST 2010


john thornton <jdthornton at ozemail.com.au> writes:

> Thanks very much for that. I went to the site and downloaded the perl
> training book. Perldocs...so many.
>
> The only part that confuses me is that if
>
> # is a comment
>
> then why does the shebang line have any influence:
>
> #!/usr/bin/perl

It has no influence on *Perl*.  That magic incantation is a Unix feature,
not a Perl feature[1].  Anyway, the particular bit of magic is:

When Linux tries to run an executable that starts with that line, it reads out
the content and transforms this:

    /path/to/example/with/shebang

...into this...

   /usr/bin/perl -w /path/to/example/with/shebang

...automatically.  From a Perl point of view it then behaves exactly the way
it would if you wrote that command out longhand.

Regards,
        Daniel

Footnotes: 
[1]  ...although IIRC it has some magic on some platforms.  Oh, well.

-- 
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons


More information about the Melbourne-pm mailing list