Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

drhyde (1683)

  (email not shown publicly)

Journal of drhyde (1683)

Friday September 24, 2004
04:07 AM

Use of "our" considered harmful

[ #21032 ]
(also posted at perlmonks. Please comment there)

Gather round, and listen to the story of a log handling utility written in perl, and a frustrated user. He's not a perl programmer, he's a Solaris sysadmin. For him, perl is just a tool, just another language. And the version of perl shipped with his Solaris is 5.005_03.

He is disinclined to build and install a new version of perl just to support a single tool. After all, he doesn't have to build new versions of awk, or new versions of C. Why should perl be any different?

Trouble is, the author of this tool didn't agree. He had used our variables instead of my. Which, of course, don't work in 5.005_03. The user was quite prepared to ditch the tool altogether and find another because it didn't Just Work. I suggested that he go through it replacing our with my and lo and behold, it worked.

The moral of this story is that even if you have the latest and greatest perl, you shouldn't use the latest and greatest features unless you absolutely must. Because if you do you will severely limit who will use your code. our in particular is really only a convenience, saving a few key strokes at most. So don't use it. Ever.

I'll buy a crate of beer for the first person who can show me some real-world code which absolutely requires our and can't be re-written to use