Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In this first section, eleven articles teach you some of the corners of Perl that you won’t find in beginner books or tutorials, but are nevertheless critical bits of knowledge.
We start with two articles by Nathan Torkington. One of the first things novices learn is that Perl has three basic data structures: scalars, arrays, and hashes. Scalars are single chunks of data, such as strings or numbers. Arrays are an ordered sequence of scalars, and Nathan’s article, All About Arrays, teaches you how to manipulate them. His second article, Perfect Programming, shows you how to program defensively, demonstrating techniques for identifying mistakes and preventing them from occurring in the first place.
Next, Mark Jason Dominus’s Precedence shows how Perl’s operators “grab” the operands around them—some tightly, some loosely, and some in ways that you were never taught in grade school. After reading his article, you’ll understand exactly when you need parentheses in your expressions. Art Ramos’s The Birth of a One-Liner then shows you why Perl programs sometimes look inscrutable to the untrained eye.
Frossie Economou’s Comparators, Sorting, and Hashes shows how to use hashes (which map strings to values), demonstrating comparators and Perl’s sorting techniques along the way. Nathan Torkington continues his explanation of Perl’s syntax with What Is Truth?
Sean Burke explains how to use others’ object-oriented code in Using Object-Oriented Modules, and Tom Phoenix explores the sometimes obscure ramifications of arithmetic on a binary computer in Unreal Numbers.
Nathan returns with his fourth article in this section, CryptoContext. The notion of context is unusual in computer languages, and confuses a lot of novices who haven’t yet embraced the notion that what you get from an operator (or subroutine) depends on how you ask for it. Ask for a number and you’ll get a number; ask for a string and you’ll get a string; ask for a list and you’ll get a list. Perl programmers call these situations numeric context, string context, and list context, respectively. Nathan focuses on the difference between scalar context and list context when calling subroutines, explaining Perl’s prototypes as an added bonus.
You can’t call yourself an experienced Perl programmer until you understand references. Mark Jason’s article, References, explains the 10% of what you need to know to get 90% of the benefit. Finally, Jon Drukman follows with an article about a few pieces of advice that are prescribed more often than followed in Perl Heresies.