I work as a professional Perl developer. We have a large and complex system which is built around a lot of Perl. This system has been in use and in place for years, and handles an astonishing amount of load, using thousands of computers to do it.

I work with some excellent engineers, who are thoughtful, intelligent, hard-working folks. They want to make the best system they can, and they want it to be reliable and dependable. I have great co-workers.

I keep finding Perl that looks like it was written in 1990. I find code like this:

sub logger { my $msg = shift; open(FH, ">>$runpath/log/output.log ") || die "Can't write output.log!" print FH "$0: $msg

"; close(FH); }

(Edit: Fixed the mistake that made the sample useless. Mark Dominus pointed out in the comments that you can’t write to a read-only file handle. << was wrong.)

The first dozen times I found code like this I thought to myself, “Ugh, old Perl. Been here for ever.” and cleaned it up. This is an old codebase – parts of it still have to be compatible with Perl 5.6, for instance – and these constructs weren’t so badly dated when the project began.

I had to stop thinking this while doing a code review of a new change. Filehandles used with the two-parameter open in brand-new code.

I stopped and asked the engineer why they’d done this. They looked at me like I was insane. Of course they’d done it that way – that’s how you open files in Perl. I had questions: “What about using a lexical instead of the typeglob?” “What about using the safer, clearer three-parameter form of open?”

I got blank stares. None of them had ever heard of these changes to open.

I’ve been educating them, which has been interesting. I’ve also been thinking about how we got here.

There’s two things I see that led to this situation, and both of them are bad for Perl.

First, many of these engineers aren’t aware that Perl is still being developed. Perl 5.8 was so stable for so long, they’ve quit watching. They think it’s done, and there’s nothing new under the sun. They bought “Learning Perl” and “Programming Perl” in 1991 and are happy with both of them. Neither of those books mentions lexical filehandles I realized the copy of “Programming Perl” on my own bookshelf didn’t.

Second, it seems like lots of people quit learning about what they’re using. It’s done, carved in stone, and that’s how they use it. The idea that the Perl community exists is odd to them, and apparently irrelevent. The ideas that Perl’s idioms might change or that new libraries, tools, and language constructs come along… these are hard ideas to convey, apparently. The question I keep getting asked it, “What’s the benefit for making these changes? What I do works, why should we change?”

Luckily for me, the project leads and our managers do understand why keeping up with the language is important, and I’m not swimming against the current to try and be bringing this new information to the team. Even so, there’s a couple of big rocks we’re having to go around.

How can the Perl community get past this huge piece of old information about the language? There are a million web sites with old examples, and thousands of outdated copies of the O’Reilly books on bookshelves. What can the community do to make it widely known that these are old, and that Perl Is Not Dead and that not only is There More Than One Way To Do It, there’s probably a Better Way now.

I worry that the addition of Perl 6 to the mix will actually make this worse. Searching for it will be hard, and how will you find examples for one or the other?

I honestly wonder if *both* languages shouldn’t change their names. Leave Perl 5 in maintenance mode forever and branch it to a new language, even if it’s just Perl 5 with better documentation. Take that time to reconsider the core modules, clean up some historical messes and release it as something new. Something that can still use CPAN, can still run all your Perl, but has active development and real, usable tools. I’d give Perl 6 a new name, too, so you can search for it properly.

Or maybe that’s the worst idea ever. I don’t know. I worry that Perl is in a bad spot now, and is trapped in the past.

Tags: Perl