The identity of those who first called Perl “the duct tape of the Internet” or a “Swiss Army chainsaw” is lost in the mists of antiquity (well, more than five years, which is the same thing in the fast-moving world of technology), but no one can argue with the importance of the language. Since its original release in 1987, it’s moved from quick-and-dirty extraction and reporting to web programming, data munging, GUI building, automation gluing, and full-blown application development. System administrators who once swore by shell scripts now break out Perl, tool programmers live on CPAN downloading modules to build on the work of others, and web administrators would never contemplate a server without a Perl install.
Like duct tape and multi-tools, Perl can do just about anything you can imagine and really want to do. If you just want to get your job done quickly, you can write the simplest, easiest Perl you know and then move on to other things. If you want to build big applications, you can do that–with some experience and a little discipline. If you want to solve your problem and don’t mind a little help, the CPAN is there to lend a hand. Larry Wall has said that Perl’s motto is “there’s more than one way to do it” but with that richness comes the question “how do I do it?”
Perl Hacks (O’Reilly) is a good start to an answer, combining the wisdom of three masters–chromatic, editor of Perl.com, Damien Conway, author of the critically acclaimed “Perl Best Practices,” and Curtis “Ovid” Poe, senior programmer at Kineticode, Inc. (developers of Bricolage)–and distilling it down into 101 hacks.
Each hack is a short lesson. Some are practical exercises that teach you essential skills, while others illustrate some of the fun things that Perl can do. Most hacks have two parts: a direct answer to the immediate problem you need to solve right now and a deeper, subtler technique that you can adapt to other situations. Learn how to add CPAN shortcuts to the Firefox web browser, read files backwards, write graphical games in Perl, and much more.
For your convenience, Perl Hacks is divided by topic–so you can skip around and stop at any hack you like. Chapters include:
Ã‚Â· Productivity Hacks
Ã‚Â· User Interaction
Ã‚Â· Data Munging
Ã‚Â· Working with Modules
Ã‚Â· Object Hacks
Perl Hacks appeals to a variety of programmers, from experienced developers to dabblers who simply enjoy exploring technology. As chromatic says, “I hope the book stimulates our readers’ imaginations and inspires them to do some hacking on their own. We could have written another 101 hacks easily (well maybe I couldn’t have; I’m pretty tired), because there’s so much more Perl to explore. Anyone comfortable with reading Perl and any Perl programmer who feels comfortable using modules from the CPAN will get something out of the book. (On the other end, I think we’ve invented a few things that even Perl gurus will have never seen before.) We tried to keep the book neutral about what readers do with Perl.”
He adds, “There are hacks on working with databases and data and hacks on using editors effectively, but most of the techniques apply to any program larger than about 10 lines. Some of them are more appropriate for larger programs, but if you write or maintain code as part of your work or hobby, we hope you can flip to a random page and learn something useful.”