Chapter 48. One-Liners

Jon Orwant

I once subscribed to the newsprint version of The Onion, a humor newspaper better known for their web site (www.theonion.com). On the Web, of course, The Onion doesn’t have to worry much about layout: their articles can be as long or as short as necessary. But on paper, they need to fill every square inch on every page with either content or ads. When room is left over, they insert a dummy article consisting of the phrase “Passers-by were amazed by the unusually large amounts of blood” repeated over and over. There were times when I wished I had done the same with TPJ.

Up until TPJ #13, I did all The Perl Journal ’s layout myself, and I almost always deferred it until a few days before printing. Magazines and newspapers typically lay out advertisements first, and flow the text around them. In contrast, I was always tweaking the articles up until the last minute, sometimes changing the length by enough that I ended up with substantial empty space on the page. Starting with TPJ #7, I began to amass a collection of “Perl One-Liners” for sprinkling around the magazine whenever I needed to fill a column-inch or two. Very few of them were actually one line, but the name stuck, and I present 65 of them here for your use and amusement.

They’re divided into two sections: Useful and Not So Useful. All the one-liners are available on the book’s web site at http://www.oreilly.com/catalog/tpj3.

Useful One-Liners

49 useful code snippets from TPJ follow. They’re organized ...

Get Games, Diversions & Perl Culture 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.