[kw-pm] Review: Perl Cookbook, 2nd ed.

Daniel R. Allen da at coder.com
Sat Feb 28 16:37:03 CST 2004


<Commercial> If there are any O'Reilly books you'd like to review, let
me know and you can get a free review copy.  They have been very good to
us; we have a 10-book lending library due to "extra" books they've sent.
Go O'Reilly! </Commercial>

Review: Perl Cookbook 2nd edition

The Perl Cookbook, by Tom Christianson and Nat Torkington, is probably
the second book many Perl programmers buy, after "Programming Perl" or
"Learning Perl."  It's often the most dog-eared O'Reilly book a
programmer will own.

It occupies its place of honour on the shelf for a good reason.  The
Cookbook introduces hundreds of recipes[1] to cover all kinds of perl
programming situations, from "How do I keep my own private module
directory?" to "How do I build a binary tree?" to "How do I intercept
Ctrl-C characters?" [2] Recipes range from half a page to half a dozen
pages.

Each recipe introduces the problem, shows a solution, discusses the
solution in depth, and most refer the reader to other sources of
solutions or documentation.  The recipes are great for answering
questions, but the in-depth discussions are where the book shines,
teaching basic and advanced perl by example.

However, the Cookbook's first edition has been showing its age; it
dates back to perl version 5.004.  (Yes, 5.004.)  Since 1998, the
language has matured significantly.  Enter the second edition, out in
August 2003, which covers up to perl 5.8.

So- a quarter-inch thicker, 175 pages longer, and $10(USD; $21 CAD)
more expensive, should you buy it?  My recommendation for anybody who
can afford the price tag[3] is a clear "yes".

There are two new chapters- one on mod_perl (including Mason and
Template Toolkit, two Apache extensions used with mod_perl) and one on
XML, which gives ten useful recipes for such things as writing XML
from data structures, validation, and reading and writing RSS (for
website syndication).

Content was rewritten throughout the second edition to accommodate
Unicode, and to note modules which moved into core Perl from CPAN.
The index is better and the binding appears to be stronger, which is
good since the book spends so much time cracked open on my desk.

According to the introduction[4], there are over 80 new recipes plus
over 100 modified recipes.  They are scattered throughout the
chapters; I didn't see any chapters that were neglected for changes,
which is good.

But the numbers mean that half the recipes are not modified.
Philosophically, are there any areas of Perl that have not progressed
in the last five years?  Shouldn't all the recipes include up-to-date
practices?  Two striking omissions seem to be: WWW::Mechanize, a
"glue" module which makes web automation easier; and anything having
to do with testing- there are no recipes discussing the excellent
Test:: modules, many which are core Perl as of 5.8.

However, practically speaking, a complete rewrite would have taken as
long as Perl 6 to finish.  That reality suggests that to keep
up-to-date, you shouldn't rely only on dead trees, but also on the Perl
community, one of the language's great strengths.

That philosophical quibble aside, I can conclude that the Cookbook is
a great way to learn features of the language, from the basic to the
somewhat arcane; and to re-remember exactly how to accomplish that
task you knew you saw a year ago but don't quite remember...

Perl Cookbook, 2nd edition
$US 49.95 / $CAD 77.95

[1] 334 in the first edition, to be exact, and 387 in the second.

[2] Chapter titles for the second edition:
     1. Strings
     2. Numbers
     3. Dates and Times
     4. Arrays
     5. Hashes
     6. Pattern Matching
     7. File Access
     8. File Contents
     9. Directories
    10. Subroutines
    11. References and Records
    12. Packages, Libraries, and Modules
    13. Classes, Objects, and Ties
    14. Database Access
    15. Interactivity
    16. Process Management and Communication
    17. Sockets
    18. Internet Services
    19. CGI Programming
    20. Web Automation
    21. mod_perl
    22. XML

[3] minus discounts - Robert Day can get it for us for something like
    $50CAD

[4] I count only 53 more recipes, but they might have removed some, or my
    counting algorithm may have been different than O'Reilly's!

--
http://kw.pm.org/ - Kitchener-Waterloo Perlmongers -          da at kw.pm.org
http://coder.com/ - Prescient Code Solutions - (519) 575-3733 da at coder.com




More information about the kw-pm mailing list