The justification for the book -- or, how to think about Perl to make learning and understanding it easier.
Fundamental features of the language and its design.
- implicit ideas
Evolution happens outside the core on purpose.
How and where to find other people to learn and to share.
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.
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?
(Don't have to be comprehensive,
$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
Describe Perl 5.10 features; mention older syntax in passing.
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)
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.
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).
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.
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,
BEGIN-time manipulations are very,
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.
return if... return unless...
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.
Use Moose instead.
postfix if and lexicals
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.
warnings by default.
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 ?