← the guideObjects Ascendant

§ 02 — Eras · 1987

Perl

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.

creators
Larry Wall, 1987
status
legacy · sysadmin scripts, bioinformatics pockets

The problem it solves

Reports, logs and glue: text processing where C was too heavy and shell too weak. Perl made the one-liner a deliverable.

The problem it carries

Write-only code — sigils, context, and “more than one way” means every script is its own dialect; the Perl 6 saga broke momentum.

Key features

context sensitivity
One value, many meanings — scalar, list or hash — decided by what surrounds it.
regular expressions, native
Pattern matching is part of the language, with substitutions and transliterations built in.
hashes and lists
The two workhorses: an ordered map and a flat sequence cover most real jobs.
the one-liner
Chained operators finish a whole job in a line — the reason Perl outlived its critics.

101 — hello, world

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).

the first program1987
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.

101 — core concepts

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;

201 — going deeper

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.

  1. references and nested structures
  2. roles over inheritance
  3. context, prototypes and warnings

references and nested structures

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)] },
);

roles over inheritance

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; ... }

context, prototypes and warnings

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 specimen — factorial

The one-liner: regular expressions in the syntax, text as the native material — the duct tape that held the early web together.

the one-liner1987
while (<>) {
  s/^\s+//;             # trim
  print if /error/i;   # filter
}

Run it today

runperl fact.pl

Where it is now

Still patching servers and genomes; CPAN was the package manager that proved the model.