The three books I'm reviewing in this installment are all from O'Reilly & Associates, but are quite different, as you will see. They are, however, all good guides to specific aspects of Perl programming that you will appreciate on your bookshelf.
I'd like to thank O'Reilly & Associates for kindly providing me copies of the books reviewed here.
This book deals with the future. The future of Perl, that is. Perl 6 Essentials is a look ahead to the new Perl 6, and the authors promise yearly revisions to keep up with the rapid pace of Perl 6 development. The authors are heavily involved in Perl 6 development, and it shows. The book is at once an introduction to the Perl 6 culture, the Perl 6 language, and the Perl 6 internals. That it succeeds at all three levels in just under 200 pages is a testament to the skill of the authors.
The book opens with an overview of Perl 6, offering enough background information to bring new Perl programmers up to date on everything they need to know, and then fills this picture out with details on how Perl 6 development works, how to go about reviewing the latest versions, and even how to follow developer releases of Perl 6.
The authors then prepare the reader for Chapter 4's discussion of Perl 6 syntax, by covering Perl principles and rules.
Chapter 4 is where the meat starts. It's a very complete summary of what you can expect in Perl 6, and if I had to pick just one chapter out of the book, this is it. Every Perl programmer should read this chapter, not just to salivate over Perl 6 features, but also to say "Gee, I never thought of that" because Perl 6 often suggests new perspectives to Perl 5 developers. The only shortcoming of Chapter 4 is that it's not intended for beginners. The material is intensely entertaining and concise, and it assumes knowledge of Perl 5 terminology and background.
Having programmed with Emacs Lisp, which supports symbol-associated properties, I am excited about Perl 6 properties, which do something very similar. Properties are sure to add a whole new "sideways" dimension to Perl programming. I say "sideways" because they provide a way to express meanings "on the side," without complicating the program's logic, and without requiring an object-oriented approach. There are many other features I haven't the space to mention. I felt like a kid in a candy store reading about junctions, currying, and all the other exciting features that Perl 6 promises.
Chapter 4 explains the Perl 6 grammars in relatively great detail,
which I certainly appreciated. The Perl 6 grammars are the one feature
that is sure to confuse, vex, and inspire programmers. They are
light-years beyond Perl 5 grammars; in fact, they are more like the
Parse::RecDescent grammars in their flexibility. If you want to
understand Perl 6 grammars, you'll have to learn more about lexing and
parsing that you probably ever wanted to.
After the fulfilling fourth chapter, Chapter 5 delves into the Parrot internals. Parrot is the engine that runs Perl 6 code, and therefore is very important for Perl 6 programming. The authors explain and defend all their design choices for Perl 6. The Parrot internals are definitely not for programming beginners. Familiarity with computer architecture, compiler internals, and even other languages such as the Java™ language helps you digest the material. To me, Chapter 5 was fascinating, but my opinion may be biased by my own experience. If you are the sort of programmer that gets excited about multimethod dispatching and iterator implementations, this chapter is for you. If you aren't, you may want to give Chapter 5 and the rest of the book only a light read this time around, and re-read the material at a later time, or again in a later version of the book (which promises to be updated in a year).
Chapter 6 answers the age-old question "Enough with the talk, can we see something happen?" The Parrot assembly language is introduced. Like Chapter 5, Chapter 6 presumes knowledge of computer architecture, and at least some experience in programming assembly language. Without those, Chapter 6 may seem cryptic.
If Chapter 4 was the Perl 6 driving manual, Chapter 6 is the engine parts list. Most of the features shown in Chapter 4 are not in Chapter 6, but the means to achieve them are. After reading this chapter, I understood the syntax and features of Perl 6 much better than before. For example, the explanation of stacks and register frames in Chapter 6 connected with Chapter 4's explanation of variable scope.
In addition, Chapter 6 has some instructions on how to get the engine parts into a whole new car, meaning that the choice of language is not exclusively Perl 6. I found it interesting to imagine how Java code or Lisp code could be expressed in Parrot assembly, in a crazy-computer-science-professor sort of way.
After all the fun of Chapter 6, Chapter 7 describes how IMCC, the Intermediate Code Compiler, can simplify much of the work involved in programming in Parrot assembly. IMCC makes life easier, but it does not take away the burden of understanding how Parrot works internally. IMCC is still a tough interface to the Parrot features.
Chapters 5 through 7 are definitely not light reading, but they are very rewarding. I hope to see more of those topics in the next edition of the Perl 6 Essentials book.
Overall, Perl 6 Essentials was a good book. I would recommend that beginner programmers wait until a more accessible book about Perl 6 becomes available, as this one condenses years of Computer Science and Engineering courses into 200 pages. For intermediate and advanced Perl programmers, Perl 6 Essentials is a must-have roadmap to the future of Perl.
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
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
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
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,
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.
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
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.
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!
- Perl 6 Essentials
(O'Reilly & Associates, 2003) covers the development not only of Perl
6 syntax but also Parrot, the language-independent interpreter developed
as part of the Perl 6 design strategy.
- Perl Cookbook, 2nd Edition (O'Reilly & Associates, 2003) is a comprehensive
collection of problems, solutions, and practical examples for anyone
programming in Perl.
- Perl Template Toolkit (O'Reilly & Associates, 2003) guides you through the
entire process of installing, configuring, using, and extending the
Template Toolkit. See also the home page of the Template
- Check out the main O'Reilly & Associates Web site for more O'Reilly titles.
- Keep up with Perl 6 news at the
main page for Parrot (and Perl 6, for now); and with the Perl 6 weekly updates.
- Bernd Dulfer's Perl6 quick reference
is an invaluable Perl 6 resource.
- You will also be interested in Larry Wall's plans
for Perl 6 regular expressions, and Allison Randall and Damian
of Larry Wall's article. See also Damian Conway's examples of
Perl 6 regular expressions in action.
- The Perl6::Rules
module for including Perl 6 regular expression syntax in Perl 5 lives at
and the Regexp::Common module at CPAN, too. Read more about Parse::RecDescent in Ted's Cultured Perl column, Writing Perl programs that speak English (developerWorks, August 2000). He discusses Tie::Hash::TwoWay in Cultured Perl: Tied variables (developerWorks, January 2003).
- Read Ted's other Perl articles in the Cultured
- Has this article gotten you into a book-buying mood? Charming
Python: Updating your Python reading list (developerWorks, May 2002) gives David Mertz' picks and
pans of Python publications.
- Find more resources for Linux developers in the developerWorks Linux zone.
- Browse for books on these and other technical topics.
- Develop and test your Linux applications using the latest IBM tools and middleware with a developerWorks Subscription: you get IBM software from WebSphere, DB2, Lotus, Rational, and Tivoli, and a license to use the software for 12 months, all for less money than you might think.
- Download no-charge trial versions of selected developerWorks Subscription products that run on Linux, including WebSphere Studio Site Developer, WebSphere SDK for Web services, WebSphere Application Server, DB2 Universal Database Personal Developers Edition, Tivoli Access Manager, and Lotus Domino Server, from the Speed-start your Linux app section of developerWorks. For an even speedier start, help yourself to a product-by-product collection of how-to articles and tech support.
Teodor Zlatanov graduated with an M.S. in computer engineering from Boston University in 1999. He has worked as a programmer since 1992, using Perl, Java, C, and C++. His interests are in open source work on text parsing, three-tier client-server database architectures, UNIX system administration, CORBA, and project management. Contact Teodor at email@example.com.