[Melbourne-pm] thanks to all

Jacinta Richardson jarich at perltraining.com.au
Thu Sep 18 02:14:15 PDT 2008


Sisyphus wrote:

>> I don't like that shebang line at all.
> 
> The shebang line is not necessary - feel free to remove it. You don't
> need a shebang line to run perl programs on any platform that I'm aware of.

Ah.  How are you running Perl?

If you're using a *nix-style platform and you set your program to be an
executable (chmod a+x hello.pl) and then call it directly ( ./hello.pl ) your
shell will fail to magically guess that it's supposed to be a Perl program.

Sure you can call it indirectly (perl hello.pl) but the shebang line is
absolutely necessary on *nix-style platforms (the Unixes, the BSDs, the Linuxes,
Apple OSX) otherwise.  This is cool because you can call your executable
something without an extension (eg cat) and run it:

	cat *.txt

without having to care what language it's written in or even whether it's a
compiled executable or an interpreted script.


The shebang line is also important for specifying options to Perl that you want
to ensure are used.  For example -w for warnings, -W for Warnings with Pride, -I
for a module path, -T for taint mode, -t for test taint mode.  Otherwise you
have to rely on the caller of your program to pass in the required switches, and
 they won't.

> Perhaps Apache requires the shebang line (I don't know) ... but even if
> that is so, it's not a criticism of perl.

The shebang line is the result of Perl coming from a background where file
extensions were unnecessary.  If you've ever had to try to convince Windows that
 MYOB data files (.pls) aren't WinAmp playlist files (also .pls) or anything
similar; you'd probably appreciate shebang lines more.

All the best,

	J

-- 
   ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
    (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
  _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
 (il),-''  (li),'  ((!.-'             |   www.perltraining.com.au   |


More information about the Melbourne-pm mailing list