Embedding Perl in HTML with Mason:

# Foreword

When Dave asked last year if I wanted to cowrite a book about Mason, I mused over the idea for a few hours but ultimately declined. I've already written a good deal about Mason in documentation and articles and wouldn't want the book to become a rehash of my particular point of view. On a more personal level, the thought of creating any text longer than a few pages fills me with trepidation. Given the choice of eight hours of backbreaking Perl coding or an hour of writing, I'd take the code any day.

This book was authored, instead, by two Mason developers who have a fresh perspective and who, apparently, like writing as well as coding. Dave and Ken have been involved with Mason for years; they've contributed to the project immeasurably, first in discussions and later to the Mason core itself. I cannot imagine two people better suited for this book.

When authors have unfettered access to the CVS repository, as Dave and Ken do, the writing process ends up shaping the product itself (e.g., "I just wrote about this feature but it turns out it doesn't exist--I'm going to implement it" or "I just wrote about this feature and it's horrible, can we kill it?"). As a result, Mason has grown over the past year in ways I never would have predicted.

Read Chapter 12, for example, to see the new parsing/compiling infrastructure so insanely flexible that one can compile Mason into Embperl or replace Mason's syntax with an XML variant. (Consider the original parser, a single 371-line subroutine, and you get an idea of how far we've come.)

Or Chapter 5 to see how "Calling Components with Content Blocks" turns content filtering from a limited hack into a first-class language feature and opens the door to the creation of custom language tags.

Or Chapter 9 to see how support for CGI (and its high-powered cousins FastCGI and SpeedyCGI) has gone from a few paragraphs in the FAQ to a full-fledged handler, inside a new modular architecture just begging for additional platforms.

Such changes expand Mason's reach to an ever larger set of problems. At the same time, the reference sections and copious recipes in this book help to fulfill Mason's original mission: to provide a fun, simple, and powerful environment for `mod_perl` development. Should we stray too far from this path, we will certainly hear of it from the users.

Reading this book has taught me a surprising number of techniques about a product I used to know everything about and has reignited my enthusiasm for building cool web applications. I hope it does the same for you.

-- Jonathan Swartz swartz@pobox.com