pound bang user bin perl it ain’t

This will be a short one. You know how to start a perl program don’t you? You know what is at line 0, starting at character 0, don’t you?


That’s it. That’s what was in front of my perl programs for years. Hell, damned near decades. Every perl program I started was


Now mind you, for a while it was

#!/usr/bin/perl -wc

But I didn’t really understand what the -wc did. I had been told that it was important, and that’s all that there was to it.  Then, when I got much smarter, it became:

#!/usr/bin/perl -wc

use warnings;

use strict;

Because I was not only very good, but very mindful. 

Then I learned, I had been doing it wrong all along. You see, @spleck came around one day and said: “why are you hardcoding the perl interpreter?” To which I replied: “What on earth do you mean? Because I am running perl.”

What if you are not running *that* perl? What if you are using some development perl that you have in your local home directory? What if you are running a perl from perlbrew? (To which I replied, what is a perlbrew?) What if you simply have more perls installed?

I didn’t have an answer. 


that’s what my fingers knew. that’s what i typed. that’s all that there was to it.

Turns out, I could have done better. And now I do.  Every time you go to write the very first line of a perl script, think of the fellow in the future, maybe you, maybe not. His computer will be different. His OS will be different. Heck, everything about their system layout might be different. Lord knows I’ve seen perl everywhere from /opt to /Library to /usr to ~/.  But you know what you can be relatively certain of? Their perl will be called perl… and the environement will know about it.

So stop it with #!/usr/bin/perl.  We have a new sherif in town, his name is

#!/usr/bin/env perl

I can’t wait for one of you internet folks to tell me why this is dumb, then I’ll tell @spleck right to his dumb face.

This entry was posted in tech and tagged , , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s