Updates

Latest Tweet



What's New?

Check out for latest innovation, a computer based training video collection


Like this Page

Perl Hacks: Tips & Tools for Programming, Debugging, and Surviving Review by Craig Maloney

An excellent way to get more out of Perl than you ever realized

Perl is my workhorse language. I've written more Perl code, both personally and professionally, than any other language I've learned. Whenever I receive a new project, I immediately think of how I would accomplish it quickly in Perl. I've also been a fan of O'Reilly's "Hacks" series of books. When I heard of the marriage of Perl and O'Reilly's "Hacks" series in the book Perl Hacks, I knew I had to pick up a copy. It was a match made in heaven. The nature of Perl for terse, yet powerful constructs, and the hackish nature of the "Hacks" series makes for one of my favorite books in this series. The collection of articles in Perl Hacks are great for putting more productivity into your programming experience.

Those of you not familiar with O'Reilly's "Hacks" Series may need an introduction. The "Hacks" Series is an ever-growing set of books with focused attention on a particular topic, like Astronomy, Mental Improvement, or even Halo 2. The books are generally short, and contain article-length "hacks" of varying difficulty, noted by a thermometer next to the hack number and description. These "hacks" fall into several categories; the non-obvious solution to a problem, the performance improvement, and the "gee, I didn't know it could do that" oddity. What makes this series special compared with other books is the willingness to "void the warranty" on a particular product, and get straight to the internals, whether they lay in hardware or software. If something can be made better by opening the covers, or twiddling with the program layout, then its eligible for inclusion in these books. The series lends itself to a wide range of topics, and the format is great for a quick read, or for (my favorite) just randomly opening the book and reading what's there.

Perl Hacks is not a book that you'd find yourself reading straight through (although you do want to make sure you visit every hack in the book at least once). The book is divided into nine chapters: Productivity Hacks, User Interaction, Data Munging, Working with Modules, Object Hacks, Debugging, Developer Tricks, Know Thy Code, and Expand Your Perl Foo. There are 101 hacks in this book, ranging from the simple (Reading files backward, or managing your module paths) to the truly perverse (Replacing bad code without touching it by substituting the system-wide exit call with your own[...]. Each hack title is listed in the table of contents, with both the page number and the hack number. Each hack contains a graphic of a thermometer next to the number to show the relative difficulty of the hack (higher temperatures = more difficult hacks). There quite a variety of hacks placed throughout the book. Not once did I feel that the book was padded with something that really didn't belong in the book. If anything Perl Hacks opened my eyes to things that I would never have thought to do, but could easily see as being useful. I wouldn't have thought to create my own personal module bundles for moving my Perl programs between machines (I've always done it the old fashioned way: run, cpan install, repeat), but hack #31 makes it so "of course" that I'm thinking of including this in all of my Perl code that I ship. Hack #74 shows how to trace all of the modules your program uses (and all of their modules, too). Hack #52 is a simple hack ("Make Invisible Characters Apparent") but I can see this saving a developer or two some time when figuring out why their code isn't behaving properly. Of course, not all hacks in the book are productive (at least, not while you're programming). Hack #37, "Drink to the CPAN" is a drinking game you and your Perl buddies may want to try.

Perl Hacks is a short book, at less than 300 pages, but it's loaded with incredibly useful information. Much like the "Perl Cookbook" (also from O'Reilly) you'll find lots of useful items hidden in their pages. Many times I started with one hack, and finished the chapter reading the rest of the hacks because there were just that interesting. Perl Hacks is highly recommended for any Perl programmer to have on their programmer book shelf. Sure, you might be able to find some of the hacks out there on the net, but I think you'll find as I have that this is more of a go-to reference for finding out some of the more interesting corners of Perl.