Book Review: Perl Best Practices by Damian Conways - Page 2

Author: DrPatPublished: Aug 31, 2005 at 5:26 pm 0 comments

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.

Continued on the next page Page 1 — Page 2 — Page 3

Article tags

Spread the word
Bookmark and Share
Profile image for drpat

Article Author: DrPat

DrPat is the blog signature used by an old coot who hoards books, dances Argentine Tango, cooks a mean venison chili, and is happy to be along for the sag while my spouse does a marathon bicycle ride. …

Visit DrPat's author pageDrPat's Blog

Read comments on this article, and add some feedback of your own

Article comments

Add your comment, speak your mind

Personal attacks are NOT allowed.
Please read our comment policy.
Please preview your comment.

blogcritics lists for Nov 24, 2009

fresh articles Most recent articles site-wide

fresh comments Most recent comments site-wide

most comments Most comments in 24hrs

top writers Most prolific Blogcritics for October

top commenters Most prolific Commenters in 24 hrs