01 — sigils & context
$, @, % tell you what a thing is; context tells you what it means. Both bite.
my @crew = ("Perch", "Sundial");
my $n = @crew; # scalar context: 2
my ($a) = @crew; # list context: "Perch"§ 02 — Eras · 1987
the duct tape of the early web — text in, miracles out
Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where Perl lives today — each column scrolls on its own.
Reports, logs and glue: text processing where C was too heavy and shell too weak. Perl made the one-liner a deliverable.
Write-only code — sigils, context, and “more than one way” means every script is its own dialect; the Perl 6 saga broke momentum.
Session one is the smallest program that still counts as speaking Perl: what every tutorial prints first, in the dialect that mattered when the language arrived (1987).
print "Hello, world\n";101First contact — hello world and 3 ideas that define how Perl reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.
3 fragments, each naming a habit of mind in Perl. Read the note, then the code — together they are the 101 in one sitting.
01 — sigils & context
$, @, % tell you what a thing is; context tells you what it means. Both bite.
my @crew = ("Perch", "Sundial");
my $n = @crew; # scalar context: 2
my ($a) = @crew; # list context: "Perch"02 — regular expressions
Regex as native syntax — the feature that carried it across the early web.
while (<>) {
s/^\s+//; # trim
print if /error|warn/i; # filter
}03 — hashes
The hash is the universal data structure — config, counting, lookup.
my %wage = (perch => 24, sundial => 31);
$wage{graymail} = 12;
print "$_: $wage{$_}\n" for sort keys %wage;The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes Perl distinctive at scale.
A scalar reference points at anything, which is how Perl expresses arrays of hashes, trees and graphs without new types.
my %crew = (
perch => { tons => 24, ports => [qw(osaka genoa)] },
sundial => { tons => 31, ports => [qw(lisbon)] },
);A role is behaviour that composes into any class, sidestepping the fragile base class problem inheritance creates.
package Sailable;
use Role::Tiny; # or Moose::Role
requires 'name';
sub sail { my $self = shift; ... }Perl’s context rules explain most of its surprises; turning on warnings and using prototypes turns the language from cryptic to merely terse.
use warnings;
use strict;
sub MAX { prototype: ($) @_ > $_[0] ? $_[0] : $_[1] }The one-liner: regular expressions in the syntax, text as the native material — the duct tape that held the early web together.
while (<>) {
s/^\s+//; # trim
print if /error/i; # filter
}runperl fact.pl
Still patching servers and genomes; CPAN was the package manager that proved the model.