For the curious, here’s how Randal tells the story of how this book came about:
After I had finished the first Programming Perl book with Larry Wall (in 1991), I was approached by Taos Mountain Software in Silicon Valley to produce a training course. This included having me deliver the first dozen or so courses and train their staff to continue offering the course. I wrote the course for them[1] and delivered it as promised.
On the third or fourth delivery of that course (in late 1991), someone came up to me and said, “You know, I really like Programming Perl, but the way the material is presented in this course is so much easier to follow—you oughta write a book like this course.” It sounded like an opportunity to me, so I started thinking about it.
I wrote to Tim O’Reilly with a proposal based on an outline that was similar to the course I was presenting for Taos—although I had rearranged and modified a few of the chapters based on observations in the classroom. I think that was my fastest proposal acceptance in history—I got a message from Tim within 15 minutes saying, “We’ve been waiting for you to pitch a second book—Programming Perl is selling like gangbusters.” That started the effort over the next 18 months to finish the first edition of Learning Perl.
During that time, I was starting to see an opportunity to teach Perl classes outside Silicon Valley,[†] so I created a class based on the text I was writing for Learning Perl. I gave a dozen classes for various clients (including my primary contractor, Intel Oregon), and used the feedback to fine-tune the book draft even further.
The first edition hit the streets on the first day of November 1993[‡] and became a smashing success, frequently even outpacing Programming Perl book sales.
The back-cover jacket of the first book said “written by a leading Perl trainer.” Well, that became a self-fulfilling prophesy. Within a few months, I was starting to get email from people all over the United States asking me to teach at their site. In the following seven years, my company became the leading worldwide on-site Perl training company, and I had personally racked up (literally) a million frequent-flier miles. It didn’t hurt that the Web started taking off about then, and the webmasters and webmistresses picked Perl as the language of choice for content management, interaction through CGI, and maintenance.
For two years, I worked closely with Tom Phoenix in his role as lead trainer and content manager for Stonehenge, giving him charter to experiment with the “Llama” course by moving things around and breaking things up. When we had come up with what we thought was the best major revision of the course, I contacted O’Reilly and said, “It’s time for a new book!” And that became the third edition.
Two years after writing the third edition of the Llama, Tom and I decided it was time to push our follow-on “advanced” course out into the world as a book, for people writing programs that are “100 to 10,000 lines of code.” And together we created the first Alpaca book, released in 2003.
But fellow instructor brian d foy was just getting back from the conflict in the Gulf, and had noticed that we could use some rewriting in both books because our courseware still needed to track the changing needs of the typical student. So, he pitched the idea to O’Reilly to take on rewriting both the Llama and the Alpaca one final time before Perl 6 (we hope). This fifth edition of the Llama reflects those changes. brian was really the lead writer, working with my occasional guidance, and has done a brilliant job of the usual “herding cats” that a multiple-writer team generally feels like.
On December 18, 2007, the perl5porters released Perl 5.10, a significant new version of Perl with several new features. The previous version, 5.8, had focused on the underpinnings of Perl and its Unicode support. The latest version, starting from the stable 5.8 foundation, was able to add completely new features, some of which it borrowed from the development of Perl 6 (not yet released). Some of these features, such as named captures in regular expressions, are much better than the old ways of doing things, thus perfect for Perl beginners. We hadn’t thought about a fifth edition of this book, but Perl 5.10 was so much better that we couldn’t resist.
Some of the differences you may notice from prior editions:
The text is updated for the latest version, Perl 5.10, and some of the code only works with that version. We note in the text when we are talking about a Perl 5.10 feature, and we mark those code sections with a special
use
statement that ensures you’re using the right version:use 5.010; # this script requires Perl 5.10 or greater
If you don’t see that
use 5.010
in a code example, it should work all the way back to Perl 5.6. To see which version of Perl you have, try the-v
command-line switch:prompt% perl -v
Here are some of the new features from Perl 5.10 that we cover, and where appropriate, we still show you the old ways of doing the same thing:
There is more information in the regular expression chapters, covering the new features from Perl 5.10. These include relative back references (Chapter 7), new character classes (Chapter 7), and named captures (Chapter 8).
Perl 5.10 includes a switch statement, which it calls
given-when
. We cover it in Chapter 15 along with the smart match operator.Subroutines now have static variables just like C does, although Perl calls them
state
variables. They persist between calls to the subroutine and are lexically scoped. We cover that in Chapter 4.
[1] In the contract, I retained the rights to the exercises, hoping someday to reuse them in some other way, like in the magazine columns I was writing at the time. The exercises are the only things that leapt from the Taos course to the book.
[†] My Taos contract had a no-compete clause, so I had to stay out of Silicon Valley with any similar courses, which I respected for many years.
[‡] I remember that date very well because it was also the day I was arrested at my home for computer-related-activities around my Intel contract, a series of felony charges for which I was later convicted.
Get Learning Perl, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.