REVIEW

Book Review: Advanced Perl Programming by Simon Cozens

Written by DrPat
Published July 29, 2005

The second edition of Advanced Perl Programming, by Simon Cozens, is very different from the first edition, because it comes into a different world of Perl programming than the first, published in 1997, did. Cozens points out in the introduction the two reasons for this shift. The first was the development and introduction of Perl 6, which had the effect of stretching Perl 5, as thousands of Perl genies found ways to make the current version do things that were promised for Perl 6.

The second reason, though, was both more subtle and more powerful, a true paradigm shift. The focus of Perl programming had shifted "away from techniques and toward resources." Knowing where to find a tasty pearl of Perl and how to plug it into your own structure has become more important than knowing how to create it in the first place, because the resources are out there.

Camel button: Powered by Perl
     Camel = PerlBecause of the shift, Advanced Perl Programming concentrates on three crafty ways to use those resources. Cozens spells them out in Chapter 1, "Advanced Techniques":

I've said that there are no secret switches to turn on advanced features in Perl, and this means that everyone starts on a level playing field, in just the same way that Johan Sebastian Bach and a kid playing with a xylophone have precisely the same raw materials to work with... First, we'll look at introspection: programs looking at programs, figuring out how they work, and changing them... The second idea we'll look at is the class model... As this is an advanced book, we're going to learn how to subvert Perl's object-oriented model... Finally, there's the technique of what I call unexpected code—code that runs in places you might not expect it to... These three areas, together with the special case of Perl XS programming... delineate the fundamental techniques from which all advanced uses of Perl are made up.

Cozens has created a map for some fairly complex territory with these three classes of approach. The first chapter comprises a kind of legend for this map, detailing some "basic" applications of each class. For example, introspection is illustrated with glob aliasing, in which the pointer for a whole group of variables is "hijacked" (purposefully) to serve another glob. From there, he takes us swiftly through accessing glob elements ("to access the individual references, you can treat the glob itself as a very restricted hash..."), closures ("a code block that captures the environment where it's defined..."), AUTOLOAD, and "two of the most misunderstood pieces of Perl arcana," CORE and CORE::GLOBAL. By page 20, Cozens has pulled these six elements into service to show the power of introspection, and he's ready to introduce "messing with the model."

Exploration is always simpler when you have a map, but any explorer will tell you, a map is not sufficient in itself. To get the most from this book, you need to be fairly familiar with Perl, and it helps to have several other languages under your belt as well. Cozens occasionally intersperses Perl examples with code from Ruby and C, but the meat of his instruction comes in showing how even frequently-used Perl goodies have little-used "hooks" that allow them to be repurposed. So although "one of the draws of Ruby is that everything is an object," but "you can't do that in Perl, [because] 2 is not an object," by manipulating the model "we can fake it."

page 1 | 2
DrPat Beard 1996 DrPat is the blog signature used by an old coot who hoards books, dances Argentine Tango, cooks a mean venison chili, and is happy to be along for the sag while my spouse does a marathon bicycle ride. All that is in my spare time — and my work life is classified...
Keep reading for information and comments on this article, and add some feedback of your own!
Book Review: Advanced Perl Programming by Simon Cozens
Published: July 29, 2005
Type: Review
Section: Sci/Tech
Filed Under: Books: Computers and Internet, Sci/Tech: Internet, Sci/Tech: Software, Review
Writer: DrPat
DrPat's BC Writer page
DrPat's personal site
Spread the Word
Like this article?
Email this
Submit to del.icio.us Save to del.icio.us
RSS Feeds
All RSS Feeds (240+)
Comments on this article
BC articles by DrPat
Books: Computers and Internet
Sci/Tech: Internet
Sci/Tech: Software
Review
All Sci/Tech Articles
DrPat's personal weblog
All Review articles
All BC articles
All BC Comments

Comments

#1 — July 29, 2005 @ 14:30PM — Aaman [URL]

If I need introspection, I'll stick with one of the .NET languages like C# - they make it so easy

Otherwise, Perl is very powerful for many tasks

#2 — July 29, 2005 @ 14:36PM — DrPat [URL]

Actually, "introspection" is used as a technique to create more-advanced Perl code. Qua introspection, it might make more sense to use another language, but that doesn't advance your use of Perl, does it?

#3 — June 23, 2007 @ 09:23AM — bliffle

I did a bunch of perl programming around 2000 and thought it greatly inferior to Java. Also, the readability of other peoples code was horrible. But the parsing expressions were useful and concise, and I see that Ubuntu commandline uses them. Perl, like C and Python and Tcl and dozens of other languages, was designed to solve about 6 programming problems out of at least 1000, and thus is lame. in 50 years of programming I've only seen a couple that are comprehensive, like PL/I and Java.

#4 — October 25, 2007 @ 05:33AM — Bill [URL]

bride-obscurity

Want comments emailed to you? No spam, promise! Address:

Add your comment, speak your mind

(Or ping: http://blogcritics.org/mt/tb/33310)

Personal attacks are not allowed. Please read our comment policy.





Remember Name/URL?

Please preview your comment!

Fresh
Articles
Fresh
Comments