Discover / Perl programming / Reading path

Learn Perl: The Best Programming Books, in Order

@codesherpaBeginner → Expert
8
Books
94
Hours
4
Stages
Not yet rated

This curriculum takes a complete beginner from zero Perl knowledge to writing real, idiomatic scripts with confidence. Each stage builds directly on the last: you first learn to think in Perl, then master its most powerful features (regexes, references, modules), and finally study professional-grade code organization and real-world application patterns.

1

Foundations: Learning to Think in Perl

Beginner

Understand Perl's syntax, data types (scalars, arrays, hashes), control flow, and basic I/O well enough to write simple, working scripts from scratch.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day (alternating between both books; start with "Learning Perl" chapters 1–6, then "Beginning Perl" chapters 1–5, then revisit "Learning Perl" chapters 7–10 for reinforcement)

Key concepts
  • Scalar variables ($), arrays (@), and hashes (%) as Perl's fundamental data types and their distinct use cases
  • String and numeric contexts: how Perl automatically converts between types and when explicit conversion matters
  • Control flow structures: if/elsif/else, while/until loops, for/foreach loops, and loop control (last, next, redo)
  • Regular expressions and pattern matching: basic syntax, matching operators (=~, !~), and substitution (s///)
  • File I/O and filehandles: opening, reading, writing, and closing files; the diamond operator (<>)
  • Subroutines (functions): defining, calling, passing arguments via @_, and return values
  • List operations: split, join, map, grep, and sort for transforming and filtering data
  • Perl's philosophy: TMTOWTDI (There's More Than One Way To Do It) and writing pragmatic, readable code
You should be able to answer
  • What is the difference between scalar context and list context in Perl, and how does each data type behave in each?
  • Write a script that reads a file line-by-line, counts occurrences of a pattern, and prints the result—without using a module.
  • Explain when you would use an array vs. a hash, and provide a concrete example of each.
  • How do regular expressions work in Perl? Write a pattern that matches email-like strings and a substitution that transforms them.
  • What does the @_ array do in a subroutine, and how do you extract and use arguments passed to a function?
  • Describe the difference between chomp, chop, and substr, and when you'd use each one.
Practice
  • Write a script that prompts the user for their name and age, validates the input, and prints a personalized greeting.
  • Create a script that reads a CSV-like file (comma-separated values), stores each record in a hash, and prints a formatted report.
  • Build a word-frequency counter: read a text file, split into words, count occurrences using a hash, and print the top 10 most common words.
  • Write a subroutine that takes a list of numbers, returns their sum and average, and demonstrate calling it with different inputs.
  • Create a script that uses a loop to generate a multiplication table (1–10), with proper formatting and column alignment.
  • Write a find-and-replace script: read a file, apply a regex substitution to each line (e.g., replace all 'color' with 'colour'), and write the result to a new file.

Next up: Mastering these foundational syntax and data-structure skills positions you to explore Perl's powerful built-in functions, modules, and object-oriented features in the next stage, where you'll write more complex, reusable, and maintainable programs.

Learning Perl
Randal L. Schwartz · 1993 · 316 pp

The canonical starting point for Perl beginners, universally known as 'the Llama book.' It introduces the language gently with hands-on exercises, covering exactly the basics needed before anything else.

Beginning Perl
Curtis Poe · 2012 · 744 pp

Complements Learning Perl by offering a slightly different angle on beginner concepts, reinforcing scalars, arrays, hashes, and file handling with more worked examples to solidify intuition.

2

Core Power: Regexes, References, and Subroutines

Intermediate

Master Perl's most distinctive and powerful features — regular expressions, references, complex data structures, and well-structured subroutines — which are essential for any real Perl work.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day (Programming Perl: weeks 1–4; Mastering Regular Expressions: weeks 5–10)

Key concepts
  • References and dereferencing: scalar refs, array refs, hash refs, code refs, and the arrow operator (->)
  • Complex data structures: nested arrays, nested hashes, and mixed structures; using references to build them
  • Subroutines: declaration, parameters (@_), return values, lexical variables (my), and scope
  • Regular expression fundamentals: patterns, metacharacters, quantifiers, character classes, and anchors
  • Regex modifiers and flags: /i, /g, /m, /s, /x and their effects on matching behavior
  • Capture groups and backreferences: parentheses for grouping, $1–$9, and using captures in replacements
  • Regex-based text processing: matching, substitution (s///), transliteration (tr///), and split with patterns
  • Advanced regex techniques: lookahead, lookbehind, non-greedy quantifiers, and performance optimization
You should be able to answer
  • How do you create a reference to a scalar, array, or hash, and what is the difference between a reference and the data it points to?
  • Write a subroutine that accepts multiple parameters and returns a reference to a complex nested data structure; explain how dereferencing works in the calling code.
  • What is the difference between /g, /i, /m, and /s modifiers in regex, and how do they change matching behavior?
  • Explain capture groups: how do you use parentheses in a regex to extract parts of a matched string, and how do you access those captured values?
  • How would you use a regex with the s/// operator to perform a global substitution, and what does the /e modifier do?
  • Design a regex pattern to validate an email address or parse a log file; explain the metacharacters and quantifiers you chose and why.
Practice
  • Build a data structure representing a small database (e.g., a list of books with authors, publication dates, and ISBN numbers) using nested hashes and arrays; write subroutines to add, retrieve, and modify records.
  • Write a subroutine that accepts a reference to an array and returns a reference to a new array with elements transformed (e.g., doubled, uppercased); demonstrate dereferencing in the caller.
  • Create a regex pattern to match and extract email addresses from a block of text; use capture groups to separate the local part from the domain.
  • Write a text-processing script that reads a log file and uses regex with /g to find all error messages; use substitution to format or anonymize sensitive data.
  • Implement a simple CSV parser using split() with a regex pattern; handle quoted fields and escaped commas.
  • Write a subroutine that takes a string and a regex pattern as arguments, then returns a hash of all matches with their positions; use lookahead or lookbehind to handle edge cases.

Next up: This stage equips you with Perl's core abstractions—references for building complex data, subroutines for code organization, and regexes for text manipulation—preparing you to tackle file I/O, modules, and object-oriented programming in the next stage.

Programming Perl
Larry Wall · 1990 · 645 pp

Written by Perl's creator, this is the definitive reference and the natural next step after Learning Perl. It covers the full language in depth, including regexes, references, and the Perl philosophy.

Mastering Regular Expressions
Jeffrey E. F. Friedl · 1997 · 488 pp

Perl's regex engine is among the most powerful in existence; this book is the gold-standard deep dive into regexes, using Perl as its primary language throughout.

3

Intermediate Perl: References, Modules, and Data Structures

Intermediate

Confidently use references to build complex nested data structures, write and use modules, and understand Perl's object-oriented system — the skills needed to read and write real-world Perl codebases.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day (mix of reading and active coding)

Key concepts
  • References as the foundation for complex data structures: scalar refs, array refs, hash refs, and code refs
  • Dereferencing techniques: arrow notation, prefix dereferencing, and when to use each
  • Building and navigating nested data structures: arrays of hashes, hashes of arrays, and deeply nested combinations
  • Packages, namespaces, and symbol tables as the basis for modular code organization
  • Writing, importing, and exporting subroutines from modules using Exporter
  • Perl's object-oriented system: bless, method calls, inheritance, and method resolution
  • References to subroutines and closures for callbacks, higher-order functions, and state preservation
  • Practical debugging and introspection techniques for references and objects
You should be able to answer
  • What is the difference between a reference and a dereference, and when would you use arrow notation versus prefix dereferencing?
  • How would you construct and access a data structure like an array of hashes of arrays, and what references would be involved?
  • What is the purpose of the Exporter module, and how do you control which subroutines are exported from your own module?
  • Explain how bless works and why it is central to Perl's object-oriented programming model.
  • How does method inheritance work in Perl, and what is the purpose of @ISA?
  • What is a closure, and how can you use code references and closures to implement callbacks or maintain state?
Practice
  • Create a reference to a scalar, array, and hash; then dereference each using both arrow and prefix notation to confirm you get the same results
  • Build a nested data structure representing a library catalog (e.g., authors → books → chapters → pages) using hashes and arrays; write code to add, retrieve, and modify entries at various levels
  • Write a module that exports a set of utility subroutines (e.g., string manipulation functions) using Exporter; import it into a separate script and verify that both @EXPORT and @EXPORT_OK work as expected
  • Create a simple class (e.g., a Person or Book class) with a constructor, instance methods, and at least one accessor method; instantiate objects and call methods to confirm bless and method dispatch work correctly
  • Implement a class with inheritance: create a parent class and a child class that overrides a method; verify that method resolution follows the @ISA array
  • Write a subroutine that returns a code reference (closure) that maintains internal state (e.g., a counter or accumulator); call it multiple times to confirm the state persists across invocations

Next up: Mastering references, modules, and objects equips you with the architectural patterns and code organization skills needed to tackle advanced topics like tie, overloading, and large-scale application design in the next stage.

Intermediate Perl
Randal L. Schwartz · 2006 · 396 pp

The direct sequel to Learning Perl (the 'Alpaca book'), it picks up exactly where the Llama left off, covering references, anonymous data structures, modules, and basic OOP in a structured, progressive way.

Advanced Perl programming
Sriram Srinivasan · 1997 · 351 pp

Bridges intermediate and advanced topics — closures, dispatch tables, templating, and CPAN module usage — giving the reader the tools to write sophisticated, reusable Perl code.

4

Professional Perl: Best Practices and Real Scripts

Expert

Write clean, maintainable, professional-grade Perl by internalizing community best practices, modern idioms, and patterns used in production scripts and applications.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day (mix of reading and active practice)

Key concepts
  • Code layout, naming conventions, and documentation standards that maximize readability and maintainability
  • Pragmas (strict, warnings, diagnostics) and how they enforce compile-time and runtime safety
  • Modern Perl idioms: postfix conditionals, statement modifiers, lexical variables, and when to prefer them over traditional constructs
  • Object-oriented Perl: packages, bless, method dispatch, and best practices for OO design
  • Regular expressions: best practices for readability, performance, and avoiding common pitfalls
  • Error handling: die, eval, exception objects, and structured error reporting in production code
  • Testing and debugging: writing testable code, using Test::* modules, and debugging strategies for complex scripts
  • Community standards: CPAN conventions, module structure, and how to write code others can maintain
You should be able to answer
  • What are the core pragmas Damian Conway recommends, and why should they be enabled in every Perl script?
  • How do modern Perl idioms (postfix conditionals, lexical variables, three-argument open) improve code clarity and safety compared to older styles?
  • What are the key principles for designing maintainable object-oriented Perl code, and how do they differ from procedural Perl?
  • How should you structure error handling in production Perl scripts to make debugging and logging easier?
  • What testing strategies and modules does Modern Perl advocate for, and how do you write testable Perl code?
  • What naming conventions and documentation practices does Perl Best Practices recommend, and why do they matter for team codebases?
Practice
  • Refactor a legacy Perl script (or write one from scratch) to follow Perl Best Practices: add strict/warnings, use lexical variables, apply naming conventions, and document with POD
  • Write a small OO module (e.g., a Logger or Config handler) using modern Perl idioms, including proper package structure, method dispatch, and error handling
  • Create a comprehensive test suite for a non-trivial Perl script using Test::More or Test::Simple; aim for >80% code coverage
  • Rewrite a complex regex to use /x modifier and comments; benchmark the readability vs. performance trade-off
  • Build a production-ready script that reads configuration, processes data, and logs errors using die/eval patterns; document error cases
  • Review and critique a peer's Perl code against Perl Best Practices checklist; identify violations and suggest improvements

Next up: This stage establishes the discipline and patterns needed to write robust, maintainable Perl; the next stage will likely deepen expertise in specific domains (web frameworks, system administration, data processing) or advanced metaprogramming, building on this solid professional foundation.

Perl Best Practices
Damian Conway · 2005 · 542 pp

A landmark book by one of Perl's most respected figures, distilling hundreds of concrete, actionable guidelines for writing readable, robust, and maintainable Perl — essential before writing any serious production code.

Modern Perl
Chromatic · 2015 · 288 pp

Covers the contemporary Perl ecosystem — Moose, CPAN, testing, and modern OOP — ensuring the reader's skills reflect how Perl is actually written and used today, not just historically.

Discussion

Keep reading

Paths that share books, cover the same subject, or open a related topic.

Shares 1 book

Learn Regular Expressions: The Best Books, in Order

Beginner6books93 hrs4 stages
More on COBOL programming

Learn COBOL: The Best Books for Mainframe Programming

Beginner6books90 hrs4 stages
More on MySQL database development

Learn MySQL: The Best Database Books, in Order

Beginner8books87 hrs4 stages
More on Godot game engine

Learn Godot: The Best Game Engine Books, in Order

Beginner7books46 hrs5 stages

More on perl programming