As Perl Debugged coauthors Peter Scott and Ed Wright observe, Perl is the most democratic of programming languages. "Those who land on its shores find an environment where they are no longer hampered by a language designer's whimsical notions of elegant semantics and stifling syntactical purity." That means Perl programmers can write useful code surprisingly quickly. Unfortunately, that code is often quite fragile, because its authors don't thoroughly understand its implications.
When it comes time to debug, these Perl developers are at a double disadvantage: Since they don't have experience to guide their intuition, they must embark on a painful trial-and-error process to figure out what went wrong, and how to fix it. Even experienced Perl developers vary widely in their efficiency as debuggers: Some handle problems with aplomb, while others of equal intelligence continually struggle.
In Perl Debugged, Scott and Wright set out to streamline the debugging process, bringing together the Perl developers the community's best wisdom on troubleshooting Perl code -- and avoiding problems in the first place. If you depend on Perl (whether as web glue or for more traditional applications), this book will save you an immense amount of frustration.
The authors begin by summarizing the "generic" (but still immensely important) methods for building more effective code -- for example, reducing the places where a bug may be introduced, by incorporating modular design, encapsulation, and unit testing. Next, you journey inside -- inside your own mind, that is. As Wright and Scott write, "the left-brain formal minutiae of creating smart code; and the right-brain, soft, touchy-feely stuff that goes on in your head. Most programmers would rather ignore the touch feely stuff because it's just Not Their Thing. However, we've found that it's more important than the rational left-brain information, because it affects everything you do."
Some of this is about the habits developers choose to learn -- precision, neatness, consistency, clarity, and a willingness to experiment ("Don't spend ages trying to second-guess the machine: find out. If you're not eager to find out what would happen in some odd situation cooked up by your fertile mind, then cultivate the attitude of curiosity, because people who have it will move along the learning curve much faster than those who don't.")
Next, it's on to what the authors call "antibugging": how to ask the right questions about what went wrong; how to document your code effectively with as little effort as possible ("we hate it too"), and exactly whom to steal good code from (they actually list 35 great Perl coders whose work is widely accessible). You'll also find specific tips on reducing complexity (first thing we do, we kill all the temporary variables).
You'll find a detailed chapter on the Perl traps that are easy to fall into if you don't know all the nooks and crannies: stuff like precedence problems, odd behavior related to autovivification and function prototypes, and so forth.
There's a full chapter on tracing code, and another on testing it (many developers don't realize how much code Perl comes with that can streamline regression testing for them). You'll also find detailed coverage of Perl's debugger -- ordinary an arcane topic, but one that this book makes far more accessible.
Scott and Wright show you how to root out run-time exceptions and syntax errors (did you know the average programmer makes one error for every 7-10 lines of code, and nearly one-fifth of those are simple typos)? There's an extensive review of the most common Perl semantical errors, and a guide to handling resource constraints (the authors remind us to optimize for people first, and only afterwards for cheap memory, processing power, or disk space).
You'll find guidance specifically targeted at developers coming to Perl from C, C++, FORTRAN, Java, or Unix shells; as well as a full chapter on CGI debugging (including how to tell if your problem is Perl related or CGI related).
In addition to being exceptionally useful, Perl Debugged is a pleasure to read. Imagine ever saying this about a debugging book: We read it end to end, and it was over too soon -- and yes, we do have a life. (Bill Camarda)
Bill Camarda is a consultant and writer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.