Tuesday, 22 November 2011

Portable shebang (for Perl)

What do you do when you have a Perl script that starts with:



Just run the script with perl like this:

$ perl my_stupid_scipt.pl

How do you avoid writing scripts like that? Do the following:

#!/usr/bin/env perl


oylenshpeegul said...

But please don't use env in system scripts. I suppose this has more to do with people writing packages for installation than it does with people writing Perl scripts, but the point stands.

Leon Timmermans said...

If you use the standard Perl toolchain (e.g. ExtUtils::MakeMaker or Module::Build), it will take care of the shebang for you. That's generally preferable.