Chapter 10. Fun with Perl

Perl programming isn’t all work and no play. Unlike many other languages, it’s in the essence of Perl culture not to take itself too seriously—thanks in part to Larry himself. After all, it’s hard to be too serious about anything whose mascot is a camel.

So Perl programmers have invented many and varied ways of amusing themselves in their time off, and understanding these things will get you a step closer to understanding Perl culture. What’s particularly interesting about having fun with Perl, though, is that it can teach you a great deal. When people are trying to squeeze every last character out of a Perl golf entry, they’ll come up with some interesting tricks in the language that you may not have thought of; part of the appeal of JAPHs is that they do obvious things in completely unexpected ways; and some of the Acme:: modules use extremely advanced or clever techniques in order to do something totally frivolous.

Some people say that you’ve really mastered a language when you can tell jokes in it; by the end of this chapter, your sense of Perl humor will be honed a little further—and, hopefully, your mastery of the language will be furthered, as well.

Obfuscation

Detractors of Perl will invariably say something about it looking like line noise; they point to wonderfully obvious, but not necessarily friendly, constructions like @{$_[0]||[ ]} as examples of how ugly Perl can turn out. (However, put the same detractors in front of a COBOL program and they’ll ...

Get Advanced Perl Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.