Starting to think about an 8th Edition

I’ve finished some other book projects (notably Learning Perl 6 and Mojolicious Web
Clients
), and it’s time to think about what I need to do to
refresh my other books.

The 7th Edition covers up to v5.24 and now we’re on to v5.30 (with
v5.32 soon). I track interesting new features at The Effective
Perler
.

Some notable things to include:

The locale’s thousands separator

Perl can use the thousands separator appropriate for your locale, as well as the appropriate decimal separator. The Number::Format from CPAN can do all sorts of interesting localizations, but POSIX can do it.

I debated offering an example in Learning Perl (7th Edition), but POSIX‘s localeconv function returns a hash reference. And, although I’ve added an appendix covering experimental features, I didn’t want to go through enough Perl to explain slices and postfix dereferencing. Continue reading “The locale’s thousands separator”

Can you learn Perl from an old Learning Perl?

A question at Yahoo! Answers asks “Is it okay to learn perl with an out-dated book?”. This showed up in my Google Alerts in a new link attractor site that wants to get referral and ad revenue. It’s a four year old question, which puts it in the desert between Perl 5.8 and Perl 5.10.

I’ve seen this question several times, and I always wonder why people want to settle for such an old book. This questioner got it from a thrift store for a penny, but most people don’t say why. Is it hard to get books where they are? Did they get it cheap in a used book store, or find it in the trash? As someone who wants to make money writing about Perl, I wonder why people either don’t have the opportunity or are reluctant to pay $20 to $40 to get the latest information and the old information usually explained better. I fully realize that prices and availability outside the United States can be a problem. If you can’t get the print book, you might be able to get the ebook version, but you need a credit card to complete the purchase from either the O’Reilly website or Google Books. As with my answers to technical questions, I’d like to know why the old-book situation exists, but people often don’t tell us why they want to settle for an ancient edition.

Before I give my answer, you should remember that I get royalties from Learning Perl, from the fourth edition on, and with increasing participation in each subsequent edition, I get a greater share. It’s in my interest that everyone gets the latest version of this book.

The reader’s interest is usually learning enough Perl to use the Perl they have available to them. Unless someone is turning on a particular computer for the first time in 10 years and want to stick with that ancient version of the operating system, I’d expect the earliest Perl they might have is something in the 5.8 series.

The questioner specifically asks about a book the covers Perl 5.004. That’s a version from 1997 to 1998, depending on the subversion you use. If the book is Learning Perl, that’s probably the second edition, released in the summer of 1997. That’s 15 years ago.

If your book is pink, it’s too old

I don’t think that you need to learn Perl from the latest book. Learning Perl, Sixth Edition covers up to Perl 5.14, but if you aren’t using Perl 5.14, you probably don’t need that edition. You might get by with Learning Perl, Fifth Edition, which covers up to Perl 5.10. If you aren’t using Perl 5.10, which is the latest unsupported version, at least for another couple of months, you might get by Learning Perl, Fourth Edition, which covers up through Perl 5.8. Even though the perl developers now release a new version of Perl every year, Perl users upgrade much more slowly, especially since each new version since Perl 5.10 has few, if none, compelling features for most people.

The further back in time you go, however, the more current practice you miss. When we update a book, we also roll in the changes to style and idiom that develop as practicing Perl programmers learn more about the consequences of the old idioms. For instance, the three-argument open was introduced in Perl 5.6, but wasn’t stressed by the community until much later. Along with that, Perl 5.6 introduced autovivified scalar filehandles. I mentioned some of these in Why we teach bareword file handles. This version of Perl was a big change in Perl practice, and as such, Perl 5.6, released in 2000, is the earliest version that I think you should even consider learning. That means that Learning Perl, Third Edition, a version in which I have no financial stake, is the minimum edition you should use.

Most of the things that you’ll learn from earlier books are still perfectly good Perl, as far as the latest compiler is concerned. The perl developers have been very keen toward supporting old Perl scripts so that the code you wrote in 1995 still works with the latest perl. Very few features (such as pseudohashes) that have ever disappeared.

There’s another point that comes up in one of the answers. The “best answer” says that it takes about a year to write a book and that by the time it hits the shelves, it’s already out of date. Neither of those things is true for Learning Perl. We do a new edition in about six months, and we plan it according to the next version of perl by following the development of the experimental version. By the time the book hits the shelf, we’re usually right on time for the latest version of Perl. For Programming Perl, Fourth Edition, we’re even a little ahead since we cover some Perl 5.16 features, and that’s not even out yet.

Updated Learning Perl, 6e ebook

There’s an updated O’Reilly ebook for Learning Perl, 6e. If you’ve already purchased the ebook, the update should already be in your O’Reilly account. I’m not sure how that works because my account has special author magic associated with it. If you don’t have an O’Reilly account, you can register your books for free.

When you report problems with the book, we usually have comments back to the publisher with a day or so telling them what to do about it. The next time our book gets built (I don’t know the schedule), you get the benefit of the fixes. The corrections should also show up in Safari. If (when) there is another printing of the book, that printing is also updated.

DocBook is a pig part of this process, and it’s going to get even better. O’Reilly has invested quite a bit in DocBook and their internal process to make the books from that. The only thing that keeps them from generating books more often is just human time. Someone has to take the list of corrections and fix them in the sources. If it’s an O’Reilly person, they have to rely on our comments about what they should do. The DocBook sources are in source control, though, and I have access to those, which means I can actually close problems by just fixing them. It takes me as long to do that as it does to explain the fix to someone. When I want to kick off a new build, I just do that.

Updates to Chapter 15, “Smart matching and given-when”

[This post notes differences between the fifth and sixth editions.]

The chapter on smart matching and given-when is the newest chapter, but also the one a bit out of date. Since we were writing the fifth edition right on the cusp of the release of Perl 5.10.0, we weren’t aware of all the problems that the new smart match feature had.

I did start to find problems, and I posted to perl6.language, perl5.porters and perlbug around the time we were turning in the book which hit the shelves in June 2008. It takes about four months to go from the end of writing to delivering the dead trees to the reader.

No one had an answer, and the next version of Perl changed quite a bit of the smart matching mechanism. For instance, see my p5p messages for [PATCH] perlsyn: equivalent code for HASH ~~ ARRAY and [perl #50538] when( @n && %n ) fails to smart match.