Chapter 5, "Variables," explores a robust (read: bug-resistant) way to code variables, whether you need to use package or punctuation variables, localization, or hash and array slicing. Conway includes plenty of code examples (for both good and bad code) to illustrate what he means. With the next chapter, "Control Structures," the book gets into more-obvious programming choices, exploring loops and if-else statements with an eye to making good decisions early in the programming process. ("Reject as many iterations as possible, as early as possible.")
It isn't until Chapter 7 that Conway addresses "Documentation," often the launching-point of other such texts. From such choices as what to put in the POD (Plain Old Documentation, the user text) and what to reserve for technical readers, Conway procedes to offer excellent suggestions to make documentation easier. Alluding to the pig's singing teacher, for example, he advises, "...don't put implementation details in the user documentation. It wastes your time, and annoys the user."
From there, Conway goes into the inner capabilities of Perl from the coder's perspective: Chapter 8 discusses the "Built-In Functions" of standard Perl code and those available from CPAN; Chapter 9 covers "Subroutines" with an eye to using them in efficient and maintainable ways; and Chapter 10 tells how to handle file "I/O" effectively. The same simple tips enliven the next chapters and explain pitfalls that lie in wait for the unwary: "References" (Chapter 11) shows how to avoid problems with symbolic and cyclic references that could lead to "memory leaks"; Chapter 12 gives guidelines for using "Regular Expressions," including the the issue of factoring alternations.
Any alternation of subpatterns can be expensive... Every alternative that has to be tried requires the regex engine to backtrack up the string and re-examine the same sequence of characters it has just rejected... nested backtracking can easily produce an exponential increase in the time the complex match requires.
The next five chapters cover programmer-designed interfaces and displays. "Error-Handling" (Chapter 13) explains why the way your code reacts to exceptions is an important part of the overall design; Chapter 14 discusses how to design a useful interface as a "Command-Line Processor". Chapters 15 and 16 cover how to create robust and efficient "Objects" and "Class Heirarchies" with little to no performance penalties, while Chapter 17 examines the most efficient ways to use object-oriented "Modules," including not only standard Perl modules, but also those found on CPAN.








Article comments