Features
- Cover Type: Paperback with 278 pages
- Published by: O'Reilly Media, Inc.; 2nd ed. edition March 8, 2006
- Written in: English
- ISBN 10 Number: 0596102062
- ISBN 13 Number: 978-0596102067
-
Book Dimensions:
8.9 x 6.9 x 0.6 inches
- Weighs: 1 pounds
Reader Reviews
This book updates the 2003 "Perl References, Objects & Modules" from the same authors, which described (in a humorous but also realistic way) a group of "Sailors" writing navigation software. First, I summarize the major changes of the new version: 1) The description of the methodology to partition software has been extended, leading to 3 separate chapters (3, 10, 15). I must say that it is not very clear why they are scattered in that order. I personally concluded that they are best read sequentially and in this order: first Chapter 10, "Building Larger Programs" (where the Sailors start reusing software first via 'cut and paste', then come to sanity via eval/do/require and finally 'package'); then Chapter 2, "Using Modules" (the natural follow up to 'package'); finally Chapter 15, "Exporter". Read in this order, they are a comprehensive and excellent overview of this subject. In the order presented in the book, they are odd (why would the sailors, after learning to use Modules in chapter 3, start 'cut and paste' and 'eval files' to reuse software in chapter 10?). 2) A new chapter "Intermediate Foundations", with a good section reminding the differences between 'eval string' versus 'eval {block }'. 3) The Testing area is enhanced with a new chapter "Advanced Testing". Information on CPAN & distributions is updated in several chapters. Also, while the examples in the book are largely the same, code style is improved; for example, the chapter on grep/map uses the 'grep { filter } array' and 'map { transform } array' style, rather than the less clear ', Expr' style of the first edition. In all, a better book (aside from the absurd chapter organization choice remarked above). For the ones who have not read the 1st edition, the strongs points of the rest of the book are: a) the chapters 5, 6 on Data Structure manipulations. The best is the way that anonymous arrays & hashes are presented, showing how they simplify the code of an example (as their introduction removes a jungle of temporary variables). Autovivification follows, with another excellent example (a "data reduction report generator"). b) chapter 7 "Subroutine References", identical to the first edition, one of the best chapters, introducing anonymous subroutines by continously refining an example, and then doing the same for "Closures". The only regret is that the final example on closures is a bit dull (as the "findFile" runs always to the end in one shot), obscuring the central capability of closures to keep each its context simultaneously (imagine an example that computes different Dna strands alternating between them, or, to stay with the book's theme, moves different boats from their initial position...). Still, for people (like me) coming from static languages, the chapter was an authentic gift. c) chapter 9 "Reference Tricks", with a great presentation of sorting, the famous Schwartzian Transform, and the processing of recursively defined data. d) finally, the chapters on Objects, and the Class Hierarchy. Remark the simple and effective presentation of Inheritance, used to factor out code common to some classes (without indulging in any of the mystical overtones that often accompany this OO subject). The points where the book is less perfect: -) Although the book wants to stop at the "Intermediate level", it could at least indicate to the reader subjects to be developed; for example, closures and mod_perl (problems with Cgi under 'registry'), need of caution with unwanted autovivifications (when testing for existence), etc. Role of lexicals vs local should also be better explained. -) Chapter 4, on References, attacks the subject of (de)referencing nested data structures. The central problem (known to strike terror in Perl tests and interviews): why do we need to write @{ $x[0] } to retrieve the array referenced by the first element of array @x? Rather than ingenious rules on "when braces are needed" and "when they can be lifted", I think it would be best to tell the facts: "Gentlemen: the dark secret here is that the sigils $, @, % bind more tightly than the [], {} and -