Skip to content

Latest commit

 

History

History
431 lines (236 loc) · 8.41 KB

outline.pod

File metadata and controls

431 lines (236 loc) · 8.41 KB

Modern Perl

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.

expressivity

expressivity *

context

context_philosophy *

implicit ideas

implicit_ideas *

perldoc

perldoc *

The CPAN

Evolution happens outside the core on purpose.

cpan *

The Perl Community

perl_community x

How and where to find other people to learn and to share.

The Language Itself

A basic explanation for elements of the language itself.

Syntactic Elements

An explanation of the individual syntactic elements which make up the language.

Names

names *

Mostly identifiers. How they work, what's valid, and what's not.

Values

values +

Strings, numbers, everything without a sigil.

Operators

This has to be more than just a list of operators (and how do you explain the difference between perlop and perlfunc?).

Control Flow

control_flow *

Loops, jumps, and labels. Defer calling functions? Exceptions??

Variables

How did I miss this one? Probably don't want to get into references yet. Should mention magic global variables.

Barewords

There are several types. Do special tokens such as BEGIN, INIT, and __END_/__DATA__ count?

Functions

Anything invocable. Again, probably don't want to get into references.

Objects and Methods

How do you discuss these without discussing references?

Data Types

Containers; Perl's built-in data types.

Scalars

scalars *

Should be simple, provided that the reference part stays put. Should mention numification/stringification, magical auto-increment.

Arrays

arrays *

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

Hashes *

Insertion order is appropriate. So is stringification.

The "variable variable name" problem.

References

Stringification and magical increment/decrement don't work. Brace disambiguation is ugly, but usually suffices.

Operators

The types of things you find in perldoc -f.

Context

context_philosophy

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.

Operator Types

Not sure what exactly this will be; perhaps infix, prefix, and built-in functions.

Coercion *

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.

Functions

Parameters

Positional, named, reference. Most people use positional; mention the others.

Context

Not sure this belongs here, but having brought it up in the context of operators, it might be appropriate. Certainly return context is interesting.

Scope

scope x

May be more appropriate conceptually before discussing parameter handling, but seems to flow better here. Difference between global and lexical.

Anonymous Functions

anonymous_functions (x)

Must come after references and functions. Mention typeglobs? The name doesn't matter to Perl. Any CV is invokable.

Closures

closures

Combines scopes, lexicals, and functions. This is the time to talk about binding and closing over. Delayed computation. Encapsulation. Abstraction.

Regular Expressions

regular_expressions *

This won't be a fun chapter, but it's a necessary chapter. What's the minimal I can write to be effective?

Basic Matching

Literals, quantifiers, metacharacters, alternations, character classes.

Regexp Flags

/e, /x, /s, /m

Compiled and Composed Regexes

qr//

Named Captures

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?

Useful Operators

Things you use all the time but might bite you.

IO

print, say, open, readline

Array Ops

push, pop, shift, unshift, splice

List Ops

map, grep, for

slicing

Ranges?

sort

List::Util

Hash Operations

keys, values, each (watch the iterator problem)

Packages * and Modules

A separate chapter?

use require import()

Objects *

Perhaps start with syntactic elements and then show Moose? Vice versa? Must cover packages and modules first, at least.

Packages

Maybe need an encapsulation and modules chapter -- BEGIN and import() plus exporting. What's the best way to export?

Blessed References

Very bare-bones object stuff. Should mention constructors.

Inheritance

Really not a fan.

Other Forms of Code Reuse

Mixins, roles.

Moose *

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?

Reflection

isa() and can()

Style

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.

Testing *

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

perldoc *

Documentation and using the documentation.

CPAN

Probably deserves its own chapter.

strict and warnings modes, use 5.010

Probably will have introduced these earlier.

Lexical Pragmas

Swap this with the previous? Depends on flow of narrative.

Code Generation

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.

Taint Mode

General security?

Exceptions?

Attributes

This is getting esoteric, and there are grotty bits of Attribute::Handlers I don't want to explain. However, they're useful.

Idioms

A handful of common idioms often found in well-written Perl programs.

Dispatch Table

"I know what action I want to take based on input I get."

Iteration

The difference between for and while.

map-based Transformations

Thinking in lists.

Or-Else/Dor-Else

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.

Dative Syntax

indirect_objects *

Barewords plus parsing sugar = avoid.

Method/Sub Equivalence

method_sub_equivalence *

The best you can do is treat them differently.

Tie

You may run into this. You shouldn't have to.

Prototypes

prototypes *

They don't work the way you think they do.

Typeglobs and Reflection

Use Moose instead.

Postfix/State

postfix if and lexicals

Avoid When Possible

Features that don't work quite right but you can't quite avoid.

Reference Syntax

Don't double $$, collapse multiple arrows, use braces copiously.

Barewords

You can almost always avoid them.

Global Variables

You only need to know a few; localize the rest.

Missing Defaults *

No strict, warnings by default. Also autodie and IO::Handle.

Blessed Hashes

Covered in OO; mention here.

isa() and can()

Maybe covered in OO?

AUTOLOAD

In general, you can avoid this.

UNIVERSAL

In conjunction with attributes....

What's Missing

Core Modules Date/Time Cookbooky Stuff Build.PL/Module::Build ?