Skip to main content

If you don't have an IBM ID and password, register here.

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

Cultured Perl: Three essential Perl books

Perl 6 Essentials, Perl Cookbook, and Perl Template Toolkit

Teodor Zlatanov (tzz@bu.edu), Programmer, Gold Software Systems
Author photo
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 tzz@bu.edu.

Summary:  In this installment, Ted reviews three Perl coding books, bringing you summaries of the key information contained in the books and how the new versions have been updated.

Date:  13 May 2004
Level:  Introductory

Comments:  

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.

Perl 6 Essentials

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.


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!


Resources

About the author

Author photo

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 tzz@bu.edu.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in

If you don't have an IBM ID and password, register here.


Forgot your IBM ID?


Forgot your password?
Change your password


By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)


By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=11389
ArticleTitle=Cultured Perl: Three essential Perl books
publish-date=05132004
author1-email=tzz@bu.edu
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).