Personal tools
You are here: Home Members spicyjack's Home Perl Hacks

Perl Hacks

chromatic, with Damian Conway and Curtis "Ovid" Poe



Brian Manning


From the back cover...

Whether you're a newcomer or an expert, you'll find great value in Perl Hacks, the only Perl guide that offers something useful and fun for everyone. With more than one million dedicated programmers, Perl's community-based development model encourages sharing of information among users and allows developers to find answers to almost any Perl question they can dream up. You can find many of these answers right here in this book.

Overall Impression

This book is all about hacks, or little pieces of code that solve some specific problem. As the back cover blurb says, any Perl user, from newbie to guru, could pull useful information from this book. People who are just starting out with Perl (you don't know Perl's basic data types, what Perl regular expressions are, or don't know what a POD page is for example) would probably do better with O'Reilly's Learning Perl, as the hacks assume some familiarity with Perl's basic syntax and how the language is structured. If you have some familiarity with Perl (intermediate user), or hack on Perl on a daily basis (you're a guru who can bless() things faster than you can sneeze), you'll have a lot more fun with the book as you will already know a lot of the terms and concepts that the book uses in the process of showing of each hack. Having had the book just under a week (July 2006), the reviewer has already dog eared several pages so as to come back to them and try them out at a later date.

Each hack is introduced with a problem looking for a solution, which the hack then proceeds to solve. All hacks are documented with sample code, and the sample code explained block-by-block. The book is not all 100% Perl either; one of the hacks is how to get the vim text editor to auto-complete variables inside of a Perl script. There's another hack that's specific to Mac OS X (how to display dialogs), but the authors expand on the hack and also tell readers how to perform the hack under Windows and Linux/Unix as well as the Mac OS X specific instructions. The authors call this "Hacking the Hack", and it serves to reenforce what the authors were trying to explain in the original hack. That pattern of taking the original hack and adapting it to similar problems is used throughout the book. Most hacks are expanded on in this fashion, so that each successive hack example is used to show more advanced concepts in Perl, as well as showing off how well the language itself can adapt to different problems. The authors do also take time to explain what are considered best programming practices, so as to help make your coding more productive and your code more maintainable. Given the wide range of hacks that are covered, the book groups the hacks into groupings that make sense, so that if one hack about databases for example does not solve your problem, you still have another eight or so hacks in the same chapter that might solve your problem instead.

The code listings for the examples used in the book are available at the O'Reilly examples website. The book's website is also available on the main O'Reilly website.

Chapters in Brief

Chapter One covers productivity hacks, with most of the hacks relating to tools that you would use to write and debug Perl code. Adding CPAN shortcuts to Firefox, running tests within the vim editor and running Perl code from within the emacs editor are some of the topics covered by the chapter.

Chapter Two is all about interacting with users, whether it be through the console, via a GUI interface, or over the web. Also covered is using SDL, a graphics library for multiple operating systems that is used primarily for writing game programs; the game Frozen Bubble is given as an example of what can be done with SDL Perl.

Chapter Three covers data munging, or manipulating data. Examples given include working with spreadsheets, as well as code related to querying SQL servers.

Chapter Four gives many hacks about Perl modules, including how to package modules for distribution, how to fix module paths easily, and even a CPAN drinking game!

Chapter Five is for object hacks. Topics covered include making methods really private, auto-declaring method arguments, and auto-generating object accessors.

Chapter Six discusses debugging in Perl. One of the best things covered in this chapter is Debugging with Test Cases, or writing Perl code that exercises your Perl code.

Chapter Seven covers developer tricks in Perl, things that the authors have used to solve more exotic problems. Lots of testing Perl code, rebuilding of Perl applications, and even a section on compiling a custom copy of the Perl binary itself.

Chapter Eight is entitled "Know Thy Code", and serves as a primer on how to find out different pieces of information about your Perl script. Inspecting data structures, tracing all used modules, finding all global variables are some of the topics covered in this chapter.

Chapter Nine is a collection of hacks that can be used to show other Perl hackers that you know your stuff. There's Perl coding skills, and Perl Foo, which is on another level entirely. This chapter deals with how to expand your knowledge of Perl Foo.

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: