![]() ![]() ![]() ![]() |
Pro Perl Debugging
by Richard Foley, with Andy Lester
APress, 2005
Reviewed by Peter Scott
APress continues to take bold risks in the Perl publishing world, for which they deserve kudos. Few people would have green lighted a project for a book solely devoted to using the Perl debugger. The closest any book previously came (aside from the miniature O'Reilly debugger Pocket Reference) was my own "Perl Debugged" (2001, Addison-Wesley), which contained a debugger tutorial, exploration of GUI front ends, and a command reference. Yet my copy of PPD arrived in hardcover, no less.This book unquestionably delivers on its promise to delve into every aspect of the debugger. If I nitpick, I could wish for an explanation of how to adjust the source window size prior to 5.8 (set $DB::preview and $DB::window), the pitfalls of watchpoints (they're not very useful on lexical variables), and more in-depth explanation of some of the options. Perhaps some more mention of how the command syntax changed considerably at Perl 5.8 would be helpful also to those many people using older perls. Foley modestly omits to say that he himself actually made that syntax change, along with a number of useful modifications to the venerable and complex debugger code.
Writing about using a debugger is a difficult task, because most of the time, the debugger is not advantageous to use on small programs. It shines when debugging huge amounts of code, twisted into labyrinthine call stacks and meandering though piles of third party modules: exactly the kind of source code you can't show in a book. And so the examples in this book are necessarily ones that you would think yield no testimonial for the debugger. Don't let that mislead you.
I know myself how uphill the battle can be to champion the debugger, having written and taught about it in the face of even Larry Wall's admission that he just uses print statements. So I'm on Foley and Lester's side here. (Andy Lester apparently came on board to get the book on schedule, hence the "with" attribution.) The debugger is a valuable tool that will save you time in many situations, and you'll learn everything you need to get it going from this book. If a GUI version is your preference, you'll get that information too. If you want to learn how to debug a program remotely - often the only choice with CGI programs - you'll find that out too. And you will also find just what you need to know to debug multiprocess and multithreaded applications.
APress still seems to be suffering from the editing problems I pointed out in my review of "Perl 6 Now", although they are not so pronounced in this book. They need to get more reviewers in their editing cycle, and tighten up the copyediting. There were no technical errors in this book, but there were a number of times that an inconsistency in the code of a developing example or another flavor of typo threw me for an annoying loop.
PPD does not limit itself to the debugger; but touches instead on valuable ancillaries such as Deparse, Xref, and modules that use the same builtin hooks as the command line debugger: coverage analysis, profiling. I thought the chapter on debugging regular expressions was superfluous, though: while it does explain in great detail the meaning of the -Dr output, it doesn't explain how it might be useful in actual debugging. Certainly, though, it would be interesting to someone who wanted to hack the Perl regex engine. I would have preferred, though, instead to have seen examples of using more of the debugger guts than just a brief example of calling the DB::DB() hook.
Expertise at using the debugger pays dividends in many circumstances, and this book will give you that expertise. It's worth the time and the money to get and read it.
© Pacific Systems Design Technologies
Revised