Higher-Order Perl

by Mark Jason Dominus

Order Higher-Order Perl online from Powell's Books

Download full text here

Donations please

If you find these materials useful or entertaining, please contribute some money to support my work.

Thank you.

There are three versions available. You have your choice of structure or presentation, but not both.

License reminder

Higher-Order Perl is copyright ©2005 by Elsevier Inc. Unauthorized reproduction or distribution is absolutely forbidden.

In particular, note that although the text is available for free, Higher-Order Perl is not in the public domain and is not available under a free license of any sort. I distribute it from this web site by virtue of special permission from the publisher. You, most likely, do not have any such permission.


This is the publisher's own PDF proof of the second version, which was sent to the printers in August 2005.

This is better than the bootleg copies available from download sites in at least three ways:

Download the whole book.

**NEW** Reformatted with less marginal whitespace for mobile devices. Thanks to Joe McMahon for providing this version.

Download individual chapters

  1. (Front matter)
  2. Recursion and Callbacks
  3. Dispatch Tables
  4. Caching and Memoization
  5. Iterators
  6. From Recursion to Iterators
  7. Infinite Streams
  8. Higher-Order Functions and Currying
  9. Parsing
  10. Declarative Programming
  11. (Index)

How was this created?

I wrote the book using a markup language I programmed myself, called MOD, which you can see in the next section. I translated the MOD to HTML and sent HTML to the publisher, Morgan Kaufmann. As you should imagine, the HTML contained very little in the way of layout and typesetting instructions.

The typesetting company hand-translated my HTML to LaTeX, which they formatted and processed with LaTeX style files provided by the publisher. The interior layout and design, including creation of the style files, was done by an unsung genius named Julio Esperas, an employee of Morgan Kaufmann. If you think the interior of the book looks good, as I do, Julio Esperas is the person who deserves the credit.

The interior illustrations were created by a company called Dartmouth publishing, from my hand-drawn originals. There were several exchanges back and forth in which I told them to make the lines in the tree diagrams curved instead of straight, to make the clouds fluffier and the parabolas more elegant.

The cover was designed by a freelancer named Yvo Riezebos.


These are the original sources that I used to generate the manuscript draft that I first sent to the publisher. They are written in MOD, a variation on the "pod" markup in which Perl's documentation is written. It should be self-explanatory. If not, drop me a note.

The big drawback of this version is that it not only omits the corrections that were added between the first and second printings, but also the much more significant corrections that were added before the first printing.

The big advantage is structural markup and tests for the code.

Download the whole book.

Download individual chapters

  1. Recursion and Callbacks
  2. Dispatch Tables
  3. Caching and Memoization
  4. Iterators
  5. From Recursion to Iterators
  6. Infinite Streams
  7. Higher-Order Functions and Currying
  8. Parsing
  9. Declarative Programming

For the index, go here instead.

MOD package

MOD was complete enough for me to write a book, but it is still incomplete. If you're feeling adventurous, you can download the source code. It is written in Perl.

Frequently-Asked Question

Q. What took you so long?


I ran outta gas. I had a flat tire. I didn't have enough money for cab fare. My tux didn't come back from the cleaners. An old friend came in from outta town. Someone stole my car. There was an earthquake, a terrible flood, locusts. It wasn't my fault!! I swear to God!!

No, that's not right. It's totally my fault. I'd explain, but it would feel too much like making excuses. Also you probably don't care about the mundane details of my life for the past four years. And anyway, even if I rehearsed the whole thing, you would be quite justified in asking, at the end of the long story, "So I don't get it. What took you so long?"

You may remember I wanted to turn the book into a wiki. That would have been awesome. But the book's fourth anniversary is coming up this spring and I have to admit to myself that I'm not gonna get the wiki together. So I'm posting the thing already.

If anyone else wants to try to turn it into a wiki, drop me a note.


Order Higher-Order Perl online from Powell's Books

Return to: Mark Dominus blog | What's new page | Perl Paraphernalia | Higher-Order Perl