The justification for the book -- or, how to think about Perl to make learning and understanding it easier.
The Perl Philosophy
Fundamental features of the language and its design.
- implicit ideas
Evolution happens outside the core on purpose.
The Perl Community
How and where to find other people to learn and to share.
The Language Itself
A basic explanation for elements of the language itself.
An explanation of the individual syntactic elements which make up the language.
Mostly identifiers. How they work, what's valid, and what's not.
Strings, numbers, everything without a sigil.
This has to be more than just a list of operators (and how do you explain the difference between perlop and perlfunc?).
Loops, jumps, and labels. Defer calling functions? Exceptions??
How did I miss this one? Probably don't want to get into references yet. Should mention magic global variables.
There are several types. Do special tokens such as BEGIN, INIT, and __END_/__DATA__ count?
Anything invocable. Again, probably don't want to get into references.
Objects and Methods
How do you discuss these without discussing references?
Containers; Perl's built-in data types.
Should be simple, provided that the reference part stays put. Should mention numification/stringification, magical auto-increment.
Make it clear that arrays and lists are very different things. Discuss distinction between indexes and length? Avoid
$# altogether? (Don't have to be comprehensive, just clear.)
$var1, $var2, $var3 -- why arrays are useful
Insertion order is appropriate. So is stringification.
The "variable variable name" problem.
Stringification and magical increment/decrement don't work. Brace disambiguation is ugly, but usually suffices.
The types of things you find in
This is perhaps the most important insight into Perl on its own as a language, so it belongs in a position where everyone will read it. It might need its own short chapter.
Not sure what exactly this will be; perhaps infix, prefix, and built-in functions.
Here's why there's a specific operators chapter. Working effectively with Perl means taking advantage of operators to enforce stringy, numeric, etc contexts on dynamic values.
Positional, named, reference. Most people use positional; mention the others.
Not sure this belongs here, but having brought it up in the context of operators, it might be appropriate. Certainly return context is interesting.
May be more appropriate conceptually before discussing parameter handling, but seems to flow better here. Difference between global and lexical.
Must come after references and functions. Mention typeglobs? The name doesn't matter to Perl. Any CV is invokable.
Combines scopes, lexicals, and functions. This is the time to talk about binding and closing over. Delayed computation. Encapsulation. Abstraction.
This won't be a fun chapter, but it's a necessary chapter. What's the minimal I can write to be effective?
Literals, quantifiers, metacharacters, alternations, character classes.
/e, /x, /s, /m
Compiled and Composed Regexes
Describe Perl 5.10 features; mention older syntax in passing.
Assertions and Extended Regexes
Briefly describe lookbehind and lookahead. Leave it at that level of detail. Mention the limitations of regular expressions? New section?
Things you use all the time but might bite you.
print, say, open, readline
push, pop, shift, unshift, splice
map, grep, for
keys, values, each (watch the iterator problem)
Packages * and Modules
A separate chapter?
use require import()
Perhaps start with syntactic elements and then show Moose? Vice versa? Must cover packages and modules first, at least.
Maybe need an encapsulation and modules chapter -- BEGIN and import() plus exporting. What's the best way to export?
Very bare-bones object stuff. Should mention constructors.
Really not a fan.
Other Forms of Code Reuse
The bare bones: classes, attributes, methods.
Note that this is the single place in the book in which I want to describe something other than the default language behavior. Hoist this up earlier?
This may need to merge with idioms. It also might get cut down too. There's a lot to say in here. I don't want to repeat Perl Best Practices, but I do want to show off some of the power of the language when used appropriately. Cutting this up between Idioms and Beautiful Features may work best.
Might explain this much earlier, right after syntactic features, so that people can use it to explore on their own (and the text can use it to show off examples).
Making the Most of Perl / Writing Real Programs
Things you must use to get the most out of Perl. Context would appear here, but it's so fundamental to understanding the language that it has to come much earlier.
Perldoc and POD
Documentation and using the documentation.
Probably deserves its own chapter.
Probably will have introduced these earlier.
Swap this with the previous? Depends on flow of narrative.
Don't want to get too far afield into
Devel::Declare and don't want to push
AUTOLOAD too heavily, but
BEGIN-time manipulations are very, very powerful.
This is getting esoteric, and there are grotty bits of Attribute::Handlers I don't want to explain. However, they're useful.
A handful of common idioms often found in well-written Perl programs.
"I know what action I want to take based on input I get."
The difference between
Thinking in lists.
The orcish maneuver.
Early Exit Guard with Postfix Conditional
return if... return unless...
What to Avoid
Here are features of Perl I wish would go away. I can't say "The internals", can I? Explain how it's so painful you wish it weren't there or how it's almost impossible to get right.
Barewords plus parsing sugar = avoid.
The best you can do is treat them differently.
You may run into this. You shouldn't have to.
They don't work the way you think they do.
Typeglobs and Reflection
Use Moose instead.
postfix if and lexicals
Avoid When Possible
Features that don't work quite right but you can't quite avoid.
$$, collapse multiple arrows, use braces copiously.
You can almost always avoid them.
You only need to know a few; localize the rest.
Missing Defaults *
warnings by default. Also
Covered in OO; mention here.
Maybe covered in OO?
In general, you can avoid this.
In conjunction with attributes....
Core Modules Date/Time Cookbooky Stuff Build.PL/Module::Build ?