Perl Cookbook, 2nd Edition
The second edition of the Perl Cookbook comes five years after the first, with deep revisions and lots of new material. It has the answer to almost every question a programmer is likely to ask about writing Perl, with examples and explanations. The authors are Tom Christiansen and Nathan Torkington, and the list of contributors to the first and second editions is a who's who of the Perl community.
The Unicode information in the Perl Cookbook's second edition is a welcome addition to the first version of the book, and is much more complete and useful than the whole Unicode chapter in Programming Perl, 3rd edition. Doubtless this is because the older text was written at a time when many of the Perl 5 Unicode features were not ready for the prime time. The Perl Cookbook coverage of Unicode is spread throughout the book, with Chapter 1 (Strings) and Chapter 8 (File Contents) getting the most new Unicode material.
Most of the chapters' contents are nearly unchanged, though individual recipes have often been updated or rewritten. In other words, the organization of question topics in the original has withstood the test of time, but the answers have evolved.
Chapter 14, which discusses database access, has been expanded
but does not mention the Class::DBI
module. For anyone working with the
Perl DBI, Class::DBI
is a viable option that should be considered. It
presents a clean object-oriented interface on top of the procedural DBI
layer. Because of the limitations of the DBI and relational databases in
general, Class::DBI
is not completely successful in this abstraction, but
it gets close enough for 90% of real-world projects. Nevertheless, the
extra coverage of database interfaces in Perl is very welcome.
Chapter 18 has coverage of Internet services already found in the first edition, with new information about mail attachments, LDAP, XML-RPC, and SOAP access. These are cool technologies, and they bring a breath of fresh air to a chapter rooted solidly in the last (twentieth) century. Unfortunately, SSH automation is not mentioned, and neither is the IMAP protocol.
Chapter 20 is about Web automation, and contains plenty of new information. It is a good resource for Web programmers, both on the client and server side.
Chapters 21 (mod_perl
) and 22 (XML) are entirely new
in the second edition. I really liked both chapters, especially because the XML chapter explained the various options available
for parsing XML very even-handedly. Anyone interested in either of the
chapters' topics should check them out, especially the concise and
immediately useful examples.
Now for the nitpicks, though in this 900+ page book there are barely any.
I wish Chapter 3 had mentioned the POSIX strftime()
function right
away in the introduction instead of as an alternative in
recipes 3.1 and 3.8. Otherwise this is a solid chapter.
I was surprised that the Schwartzian transform in recipe 4.16 was not mentioned by name, even though it was very recognizable.
I should mention that recipe 5.9, "Inverting a hash," can also be done
with my Tie::Hash::TwoWay
CPAN module, which does a lot more than what the
recipe shows (if I do say so myself!).
It would have been nice if the recipes were marked with the version of Perl that supports them. There are still many 5.005 and 5.6.1 installations of Perl, the upgrade for which is not going to happen soon for the usual reasons.
Chapter 15 should have mentioned the AppConfig
module from CPAN,
which presents a different and, I think, nicer interface to command-line
options than the standard Perl Getopt
modules. For instance, AppConfig
is
object-oriented, unlike Getopt
; it also supports reading configuration
files with the same option syntax that's available from the command line.
After finishing the second edition of the Perl Cookbook, I felt ready for the challenges of programming Perl in today's environment. Where the first edition seems inadequate today because of technologies that have emerged since its printing, the second edition again provides a stable foundation for any Perl programmer, beginner to advanced. I recommend the Perl Cookbook strongly, even for those who already have the first edition.
Perl Template Toolkit
The Perl Template Toolkit (TT) is one of my favorite tools for Web development. I was excited about the book on TT, since it is written by the authors of TT.
The TT book has a similar layout to the classic "Learning Perl" layout, with a quick introductory chapter on the essentials followed by longer explanatory chapters. Chapters 1 through 6 follow this strategy; the TT language, directives, filters, and plug-ins are explained in very satisfactory detail. Even though I have been a TT user for years, I found new information on almost every page, either in a function or in an example given. Reading the TT online documentation is useful, but the TT book is definitely the better way to learn how to use TT to its fullest potential.
Chapters 1 through 6 are suitable for beginners and advanced Perl programmers alike. The TT language is a unique beast, but anyone will find it easy after reading the TT book.
Chapters 7 through 12, however, are much more advanced. At the very least, the reader should be familiar with Perl object-oriented programming (OOP) and HTML programming. Chapters 9 (on database access) and 10 (XML) are a bit more accessible, but some real-life experience with databases and XML, respectively, is very helpful. This is not the fault of the TT book authors; databases and XML are complicated topics with deep roots in computer science and engineering.
The "view" feature of TT, discussed in Chapter 3, left me excited
but questioning why it's so limited. If different views can be provided
for hashes, arrays, and scalars, why stop there? The views should be
declared based on class name, so an object of class "A::Beta
" could have a
different dynamic view from "A::Gamma
" without any extra work on the
programmer's part. This was just about the only significant question I
had; there is almost nothing I can nitpick in the TT book.
The TT book authors try very hard to keep TT a presentation vehicle
only, without executable logic. In fact, there are cases (such as the
mod_perl
examples) where an entirely self-contained TT template can be a
good thing, and breaking the rules a little can reap big benefits. Kudos
to the book authors for sticking with the purpose of the TT, yet
recognizing that no rules are absolute, especially when it comes to Web
programming under mod_perl
.
Overall, the TT book is an exhaustive, fascinating look at the Perl
Template Toolkit. Anyone interested in Web development, with or without
mod_perl
, must look at the TT book as at least a comparison point with
other templating systems. The TT is useful for so many other purposes, and
the book explains them so well, that I heartily recommend the TT book to
any Perl programmer, beginner to advanced.
A look back
The books I reviewed here are all very good. The intended audience of the Perl 6 Essentials book is not the entire Perl community, but it does include anyone interested in Perl 6. Readers with intermediate to advanced Perl skills will definitely find this book more useful. It's also important to note that the first edition will "expire" in a year, made obsolete by a new edition tracking the development of Perl 6. Nevertheless, this is a well-written book with a wealth of information about Perl 6. Chapter 4 is especially good.
The Perl Cookbook, 2nd Edition, is an excellent resource for every kind of Perl programmer. I recommend it without reservations, and I'm sure it will be useful for years to come.
The Perl Template Toolkit book is a fascinating book, covering the Template Toolkit in excellent detail. I recommend it to all Perl programmers, and I think beginner programmers will find the first 6 chapters especially useful. Programming with templates is, like using source version control and eating chocolate, highly addictive. Don't blame me if you get hooked!
View Cultured Perl: Three essential Perl books Discussion
Page: 1 2 3 Next Page: Resources