Author: brian d foy
Audience: Intermediate/Advanced Perl programmers
Reviewer: Nikos Vaggalis
This is a book for experienced Perl programmers, who should at least have read the other two books of the trilogy, Learning Perl and Intermediate Perl. Even if you do belong to that category, you will probably find this book requires some effort.
Apart from demonstrating some coding techniques, this book is not about coding applications but rather about describing the infrastructure necessarily for building faster, better, maintainable programs. As such, I would logically divide the content like this:
- The Tools: Perl Debuggers, Profiling Perl, Benchmarking Perl, Cleaning Up Perl, Logging
- Maintainability: Configuring Perl Programs, Modules as Programs
- Preparing for the Unexpected: Secure Programming Techniques, Detecting and Reporting Errors
- Coding: Symbol Tables and Typeglobs, Dynamic Subroutines, Modifying and Jury-Rigging Modules, The Magic of Tied Variables
- Misc: Advanced Regular Expressions, Data Persistence, Working with Pod, Working with Bits
That my proposed structure for the book. Now lets see how foy goes about it
Chapter 1 "Advanced Regular Expressions" doesn't joke around. It gets steep right away by building a crude makeshift parser and, later on, by going through the concept of recursive regular expressions; as such you must be confident in your knowledge of Perl's regular expressions before tackling this one.
Chapter 2 "Secure Programming Techniques" contains practical tips on how to code defensively, being careful with the external data feeding your program. Taint Checking and the List Forms of system and exec are some of the preventative measures presented.
The next chapters, Perl Debuggers, Profiling Perl, Benchmarking Perl and Cleaning Up Perl are about the tools of the trade and the proper way of using them. The same tools (debugger,profiler,etc) and raw materials can be used by the master and the inexperienced alike but the difference is on the know how. Only the master will pose the techniques that enable him to cut development time and produce high quality fault-resistant code.
At this point, I should note that what the reader should actually try to do is to assimilate the mentality of the master rather than look at it as just a how-to guide. The author clearly presents his pattern of thinking, always explaining his choices, so you learn how to think in the same way and apply that mindset to your own challenges; I think that that’s the most valuable aspect of the book.
Although it looks like the chapters are self contained, chapters 7 "Symbol Tables and Typeglobs", 8 "Dynamic Subroutines" and 9 "Modifying and Jury-Rigging Modules" have to be read in that order to make sense and provide a complete picture, with the foundation laid in Chapter 7, where the concept of the symbol table is discussed. Dynamic Subroutines" could also go under "Tricks to play with subroutines" since it covers them extensively, presenting intuitive ways of using them. The third of these chapters examines the alternative paths one could take for modifying third party source code, ultimately leading to the replacing a module's parts at runtime , or monkey patching a la Perl style, that way injecting a sense of AOP.
The chapter on "Configuration", or how the environment can affect your program's runtime, contains advice on how to help yourself regarding your program's interaction with its users. Make it configurable to satisfy their needs for customization otherwise you risk them breaking your program because of them fiddling with the source.
Chapter 11, "Detecting and Reporting Errors" is the highlight of the book, I think. Nice, crisp explanations of the basics, concepts, errors , exceptions and reporting when things go wrong.
The "Working with Bits" chapter feels like material sprung out of a Computer Science class, while "Appendix A, Further Reading" sheds light onto another aspect of being a master; the master should not only study his specialty but be interested in the craft as a whole and should therefore read non Perl books as well. Hence, some very interesting titles are recommended.
Often appendixes contain non-essential info that does not fit with the rest of the content, but in this case, "Appendix B, brian’s Guide to Solving Any Perl Problem", proves to be very valuable as he provides his approach to problem solving as inheritance for the next generation of programmers
Wrapping up, this title is best approached like taking a peek into the treasure chest containing the journals of a master; it contains his condensed experience jammed inside a book. You'll get the most out of it if you can capture the way the master thinks and works and assimilate that for your own benefit .
But, do I feel like a master after completing it ? Certainly not, as the path to mastery requires much more than just reading a book. But it certainly makes for a strong push to the right direction.