Not Magic (Perhaps), but the Key to Unlocking Advanced Perl Skills
by Simon Cozens
Once you’ve read a good Perl book–the Camel Book, for instance
(“Programming Perl”)–or any other good tutorial, you know almost all of the
language. Some Perl programmers may react with dismay at Simon Cozens’s
observation in the new edition of “Advanced Perl Programming” (O’Reilly, Second Edition), “There are no secret keywords, no other magic sigils that turn on Perl’s advanced mode and reveal hidden features,” he admits. “In one sense, this book is not going to tell you anything new about the Perl language.”
What, then, lies ahead for Perl programmers? Is it a matter of “See Rome and die?” Not according to Cozens. “I used to be a student of music,” he says.
“Music is very simple. There are 12 possible notes in the scale of Western
music, although some of the most wonderful melodies in the world only use, at most, eight of them. There are around four different durations of a note used in common melodies.” As Cozens points out, there isn’t a massive musical vocabulary to choose from, and yet music has been around a great deal longer than Perl.
“I’ve said that there are no secret switches to turn on advanced features in
Perl,” Cozens further explains. “This means that everyone starts on a level
playing field, in just the same way that Johann Sebastian Bach and a little kid
playing with a xylophone have precisely the same raw materials to work with. The
key to producing advanced Perl–or advanced music–depends on two things:
knowledge of techniques and experience of what works and what doesn’t.”
The new edition of “Advanced Perl Programming” aims to give readers some of each of these things. The book was written not for advanced Perl programmers, but for any Perl programmer who would like to become a better Perl programmer. It
covers all the complex techniques for production-ready Perl programs, clearly
explaining concepts such as introspection, overriding built-ins, extending Perl’s object-oriented module, and testing code for great stability. Other
topics include parsing, templating tools, Unicode, interaction with C and
other languages, and working with natural language data. In addition,
this guide demystifies topics such as object-relational mapping and
event-based development. As Cozens notes, “The variety of topics covered in the book means there’s going to be something for every programmer here.”
Some programmers may question why a new edition of “Advanced Perl Programming” is necessary, considering that the language itself has not changed dramatically in recent years. As Cozens explains, there’s unquestionably a necessity for the new book. “The first edition of ‘Advanced Perl Programming’ has long been a mainstay for Perl programmers attempting to further their skills, but unfortunately it hasn’t caught up with the developments in Perl over the past five years,” says Cozens. “Specifically, the focus of development has shifted from writing complicated code yourself to using other people’s complicated code available from CPAN. So advanced Perl programming has changed in its nature, and I wanted to update the book to reflect that.
“My hope is that readers will discover that someone has already done the hard
work for them; that there’s a huge collection of ready-made modules out there, and at least one of them will apply to whatever they’re trying to do. Maybe my book won’t give them the exact answer they need, but it will hopefully open their eyes to where to find the answers.”
Perl programmers looking for a magic switch to turn on advanced skills will come up empty-handed, but “Advanced Perl Programming, Second Edition” will help push their skills to the next level to become more accomplished programmers.
Early praise for “Advanced Perl Programming”:
“Simon Cozens notes that once you know the syntax there’s no more Perl to learn.
In this book, he shares advanced techniques for applying the Perl you (mostly) already know… It’s a shame for the Perl community that Simon’s moved on to other things, but this book is a fine legacy from which the rest of us can try
to live up to his standards.”
–Smylers, The Perl Review
“It has been said that sufficiently advanced Perl code is indistinguishable from magic. This book of spells goes a long way to unlocking those secrets. It has the power to transform the most humble programmer into a Perl wizard.”
–Andy Wardley
“The information here isn’t theoretical. It presents tools and techniques for
solving real problems cleanly and elegantly.”
–Curtis “Ovid” Poe
“‘Advanced Perl Programming’ collects hard-earned knowledge from some of the
best programmers in the Perl community, and explains it in a way that even novices can apply immediately.”
–chromatic, editor of Perl.com
Table of Contents
Preface
1. Advanced Techniques
Introspection
Messing with the Class Model
Unexpected Code
Conclusion
2. Parsing Techniques
Parse::RecDescent Grammars
Parse::Yapp
Other Parsing Techniques
Conclusion
3. Templating Tools
Formats and Text::Autoformat
Text::Template
HTML::Template
HTML::Mason
Template Toolkit
AxKit
Conclusion
4. Objects, Databases, and Applications
Beyond Flat Files
Object Serialization
Object Databases
Database Abstraction
Practical Uses in Web Applications
Conclusion
5. Natural Language Tools
Perl and Natural Languages
Handling English Text
Modules for Parsing English
Categorization and Extraction
Conclusion
6. Perl and Unicode
Terminology
What Is Unicode?
Unicode Transformation Formats
Handling UTF-8 Data
Encode
Unicode for XS Authors
Conclusion
7. POE
Programming in an Event-Driven Environment
Top-Level Pieces: Components
Conclusion
8. Testing
Test::Simple
Test::More
Test::Harness
Test::Builder
Test::Builder::Tester
Keeping Tests and Code Together
Unit Tests
Conclusion
9. Inline Extensions
Simple Inline::C
More Complex Tasks with Inline::C
Inline:: Everything Else
Conclusion
10. Fun with Perl
Obfuscation
Just Another Perl Hacker
Perl Golf
Perl Poetry
Acme::*
Conclusion
Index