Perl One-Liners: book review

Perl-one-liners

Perl One-Liners

I was recently contacted by No Starch Press and they gently offered to send me a copy of “Perl One-Liners“, a book by Peteris Krumins.

Before looking at the book itself, it’s interesting to see that the author is a serial-oneliner-author, if I can say: Perl One-Liners is his third book on the topic, after Awk One-Liners Explained and Sed One-Liners Explained. I think Peteris bash history must look a bit scary to unprepared eyes!

So, as you can guess the book is about oneliners, those magic-and-cryptic commands some bearded sysadmins use everyday to tell their servers what to do (Wait? This last sentence is a cliché? No way!).

The book’s cover looks nice and fresh, I must say the first impression is good, it’s nice to see new Perl books published with nice and eye-candy artworks. Speaking of the artwork, it’s funny to see that a one-liner is here associated to a telegram machine, as if this was the antic way of communicating with a computer. Or maybe that’s more about the compact size of the instruction sent. Anyway, let’s look more at the content!

A quick glance at the table of contents tells everything: this book is a cookbook for the sysadmin. The title tells no lies, it’s not a guide to enlightened modern Perl programming, but more something like: How to use Perl as a swiss-army knife, on the command line. Which is indeed another interesting angle to look at Perl.

The table of contents gives the full overview of what you can find: one-liners grouped by topics (Spacing, Numbering, Calculations, Array and Strings, Text Conversions, Printing and Deleting Lines, Regular Expressions).

I won’t comment on all the one-liners (130 of them in the book!) but I can say that this book can be a good companion to learn how to use Perl on the command line.

By reading this book and trying the recipes, you’ll master shortly all the command-line options that can turn the Perl interpreter into a sed-awk-grep-toolboox-on-steroids. Indeed, here is the real lesson you’ll find in that book: beyond the 130 examples, you’ll get to understand how and when to use flags like -p, -l, -i or -n, which will let you write your own one-liners in no time when needed.