Higher-Order Perl

1st Edition

Transforming Programs with Programs

Print ISBN: 9781558607019
eBook ISBN: 9780080478340
Imprint: Morgan Kaufmann
Published Date: 14th March 2005
Page Count: 600
62.95 + applicable tax
49.99 + applicable tax
81.95 + applicable tax
Compatible Not compatible
VitalSource PC, Mac, iPhone & iPad Amazon Kindle eReader
ePub & PDF Apple & PC desktop. Mobile devices (Apple & Android) Amazon Kindle eReader
Mobi Amazon Kindle eReader Anything else

Institutional Access


Most Perl programmers were originally trained as C and Unix programmers, so the Perl programs that they write bear a strong resemblance to C programs. However, Perl incorporates many features that have their roots in other languages such as Lisp. These advanced features are not well understood and are rarely used by most Perl programmers, but they are very powerful. They can automate tasks in everyday programming that are difficult to solve in any other way. One of the most powerful of these techniques is writing functions that manufacture or modify other functions. For example, instead of writing ten similar functions, a programmer can write a general pattern or framework that can then create the functions as needed according to the pattern. For several years Mark Jason Dominus has worked to apply functional programming techniques to Perl. Now Mark brings these flexible programming methods that he has successfully taught in numerous tutorials and training sessions to a wider audience.

Key Features

  • Introduces powerful programming methods—new to most Perl programmers—that were previously the domain of computer scientists
    Gradually builds up confidence by describing techniques of progressive sophistication
    Shows how to improve everyday programs and includes numerous engaging code examples to illustrate the methods


Intermediate to advanced Perl programmers

Table of Contents

  • Preface
  • 1. Recursion and Callbacks
    • 1.1 Decimal to Binary Conversion
    • 1.2 Factorial
      • 1.2.1 Why Private Variables are Important
    • 1.3 The Tower of Hanoi
    • 1.4 Hierarchical Data
    • 1.5 Applications and Variations of Directory Walking
    • 1.6 Functional vs. Object-Oriented Programming
    • 1.7 HTML
      • 1.7.1 More Flexible Selection
    • 1.8 When Recursion Blows Up
      • 1.8.1 Fibonacci Numbers
      • 1.8.2 Partitioning
  • 2. Dispatch Tables
    • 2.1 Configuration File Handling
      • 2.1.1 Table-driven configuration
      • 2.1.2 Advantages of Dispatch Tables
      • 2.1.3 Dispatch Table Strategies
      • 2.1.4 Default Actions
    • 2.2 Calculator
      • 2.2.1 HTML Processing Revisited
  • 3. Caching and Memoization
    • 3.1 Caching Fixes Recursion
    • 3.2 Inline Caching
      • 3.2.1 Static Variables
    • 3.3 Good Ideas
    • 3.4 Memoization
    • 3.5 The Memoize Module
      • 3.5.1 Scope and Duration
        • Scope
        • Duration
      • 3.5.2 Lexical Closure
      • 3.5.3 Memoization Again
    • 3.6 Caveats
      • 3.6.1 Functions whose Return Values do not Depend on their Arguments
      • 3.6.2 Functions with Side Effects
      • 3.6.3 Functions that Return References
      • 3.6.4 A Memoized Clock?
      • 3.6.5 Very Fast Functions
    • 3.7 Key Generation
      • 3.7.1 More Applications of User-Supplied Key Generators
      • 3.7.2 Inlined Cache Manager with Argument Normalizer
      • 3.7.3 Functions with Reference Arguments
      • 3.7.4 Partioning
      • 3.7.5 Custom Key Generation for Impure Functions
    • 3.8 Caching in Object Methods
      • 3.8.1 Memoization of Object Methods
    • 3.9 Persistent Caches
    • 3.10 Alternatives to Memoization
    • 3.11 Evangel


No. of pages:
© Morgan Kaufmann 2005
Morgan Kaufmann
eBook ISBN:
Paperback ISBN:


“It's well written…everyone who claims to be an expert ought to read it…these techniques allow programmers to accomplish far more than they're used to."
—Gregory V. Wilson, Dr. Dobb's Journal, November 2005

"It is, quite simply, one of the best books on programming I have read for a long time."—Martin Schweitzer, Computing Reviews, Association for Computing Machinery, July 2005

"Mark Jason Dominus has hit his mark with Higher Order Perl. It is a very informative book that is a must read for Perl programmers who want to take their skills to the next level.”
—Mark Rutz, Linux Journal, November 2005

“Higher-Order Perl is one of the Perl books that should have a place on the bookshelf of every Perl programmer. It offers an in-depth understanding of important programming techniques and fundamental concepts. The chapter on parsing alone is worth the price of this book. I do not know a better text about parsing in Perl.”
—Reinhard Voglmaier, Unix Review, November 2005

“Higher-Order Perl is the most exciting, most clearly-written, most comprehensive, and most forward-looking programming book I've read in at least ten years. It's your map to the future of programming in any language."
—Sean M. Burke, Leading Programmer, Comprehensive Perl Archive Network (CPAN)

"There are lots of book that teach you new Perl modules or techniques. This book goes beyond that and teaches a new way to think about Perl programming.”
—Peter Norvig, Google Inc.

“As a programmer, your bookshelf is probably overflowing with books that did nothing to change the way you program. . . or think about programming.

You're going to need a completely different shelf for this book.

While discussing caching techniques in Chapter 3, Mark Jason Dominus points out how a large eno