Perl Tips

08/29/2005 08:48:01

ComputerStuff

This page largely exists for me to record some scraps of information so I don’t forget them over time. ;)

Shebangs

A while back, I found a way of writing the shebang line for perl scripts to make it more compatible with different servers. For instance, my home machine and my web server account have the perl executable in different places. Therefore, the usual shebang doesn’t work on both:

#!/usr/bin/perl

So when I copy a script from home to my server, I have to edit it, and vice-versa.

I have been searching to try and find this alternative method for a few weeks, and I think I stumbled across it last night:

#!/usr/bin/env perl

This works on both machines. Now, obviously, there are some machines that don’t store env within the /usr/bin directory. But for many of us, this format is more compatible. There may be other ways of doing this sort of thing, and I would love to hear about them.

Hopefully someone else will find this of use. If not, at least I can find it again if I forget down the road.

Similar Pages

Comments

Leave a comment