Evaluating a Good Perl Book
The popularity of the Perl programming language has surged more than once, and every surge brings a new wave of tutorials and books. Perl has always been a flexible language, preferring to allow people to get things done with little ceremony than to require strict adherence to a set of rules and guidelines.
Sometimes this allows people to make messes. Sometimes these messes find their way into books.
Fortunately, many good books exist. There's no general rule for determining whether any given book is worth your time, but you can rule out several possibilities by following these guidelines.
How old is the book?
Even though Perl itself dates from 1987, the language changes and evolves. The most important developments in modern Perl started in 2000 and have only accelerated since then. A book from 2000 is far out of date, while a book from 2006 may miss out on some of the enhancements in modern Perl.
Keep in mind that Perl 5 has a yearly release schedule. A book which covers Perl 5.8 is several versions behind the oldest version of Perl supported by its developers.
The book doesn't necessarily have to target a specific release of Perl—in the case of an introductory book, this is almost a given—but it ought to mention the version of Perl used in the examples.
Does the book explain context?
Context—the difference between wanting zero, one, or many things and the difference between treating something as text versus as a number—is central to the Perl philosophy. Does the book explain it?
In particular, does the book explain how to count the number of elements in an array? It should suggest something like "evaluating the array in scalar context" produces the desired result. (It's okay not to understand what this means right now. If the book says something like that, you should understand it by that point.)
For bonus points, does the book explain some of the less expected parts of context? For example, does it mention what you get when you evaluate a hash in scalar context? Does it mention value contexts, such as string and boolean and numeric contexts? (It doesn't have to describe them as contexts, but it should explain how typed operators coerce their operands.)
This applies more to introductory texts than to more specialized books.
Does the book cover testing?
One of the most important developments in modern Perl is the ubiquity of automated testing. The Perl language and its core libraries have hundreds of thousands of automated tests, and the CPAN has countless more.
Any good Perl book should at least mention testing, and that mention should include core tools such as Test::More, Test::Harness, and prove.
Does the book cover the CPAN?
Modern Perl programmers often say that 80% of every program is already written and available on the CPAN. Any decent book should mention this. A good book should demonstrate how to set up the CPAN client and use a module.
A very good Perl book will explain how to structure your own code to follow the CPAN module style. (This may not apply to introductory books.)
Does the book cover warnings and strict?
These options allow Perl to detect potential errors in your programs. This will help you write better code (and learn to code defensively). Every good Perl book explains how they work and how to use them and why. This is more important in introductory books, but other books should at least explain that all code examples use those options by default (or disable them explicitly).
Does the book explain tainting?
Perl's taint mode helps detect unsafe uses of untrusted user input. If the book explains tainting and how to use it, give it an extra point to its credit.
How practical is the book?
By the first few examples, you should understand values and variables. You should especially understand the need to declare variables, and why lexically scoped variables are valuable. After the first couple of chapters, you should be comfortable with file handling. You shouldn't go much further into the book before it explains things like regular expressions, subroutines, and functions. No introductory Perl book should leave out things like references and dereferencing, recursion, lexical scoping, and packages. You can get away without describing object oriented Perl only if you have a very narrow and focused didactic scope (and refer to other resources for more information).
A really good book will introduce things you never knew about, such as the Catalyst, Dancer, or Mojolicious web programming framework or any of a dozen other wonderful CPAN modules (DBI, Perl::Critic, Devel::NYTProf, et cetera). You might even walk away knowing more about computer science concepts such as recursion and eval. (The book >Higher Order Perl is a wonderful example.)
(Some people will disagree, but a good Perl book can still be a good Perl
book even if it doesn't mention obfuscated Perl or some of the Unix roots of
Perl. You can look up sprintf
in the perldocs, but only if
someone's taught you how.)
Is the author a well-known Perl programmer
Most good books come from authors with modules on the CPAN, authors who participate on Perl mailing lists or forums such as Stack Overflow and PerlMonks, and authors who are generally well known in the Perl community.
If you search for the author's name, you should find him or her mentioned in the context of Perl in at least one of these cases.
Does the book refer to the documentation?
Except in the case of Programming Perl, where the book is almost as large as—and in many cases is written by the same people who wrote—the core documentation, a very good Perl book will explain that Perl itself comes with plenty of documentation and will explain where to find relevant information in the documentation itself.
Does the book have recommendations from other well-known Perl programmers?
If you're fortunate enough to work with other good programmers, take their recommendations seriously. If you don't have personal contacts, consider asking your local Perl Mongers group for information, or checking with a forum such as PerlMonks.
The Best Perl Books
This list is not exhaustive, but it does include some of the best Perl books available today.
Best Books for Learning to Program with Perl
Learning Perl, 6th edition is the latest version of the text countless programmers have used to teach themselves to program Perl. It assumes little programming knowledge and demonstrates the most essential parts of the language.
Beginning Perl is a comprehensive guide to the Perl programming language. While it focuses on the practical language as you're likely to encounter it, the book covers topics working programmers need to know to be effective.
Best Books for Perl Programmers
Intermediate Perl begins where Learning Perl ended. You already know Perl. If you want to build on your skills to build larger, more powerful, more robust programs—to solve bigger problems faster and better—you need to know what's in this book.
Modern Perl is the only book which focuses on helping you understand the philosophy of the Perl language. Yet rather than being a dry tome, it provides an easy and simple explanation of how the language works and how you can take advantage of its best features to solve real problems effectively and completely.
Programming Perl is the definitive guide to the Perl programming language, as told by Perl's author and some of its most experienced developers. Anything you could want to know about the language (and many things no one has discovered until now) is between these covers. This may not be the first Perl book you read, but there's a reason every serious Perl programmer talks about the Camel book. This is that book.