Embedding Perl in HTML with Mason
by Ken Williams, Dave Rolsky
The unconfirmed error reports are from readers. They have not yet been
approved or disproved by the author or editor and represent solely the
opinion of the reader.
Here's a key to the markup:
[page-number]: serious technical mistake
{page-number}: minor technical mistake
: important language/formatting problem
(page-number): language change or minor formatting problem
?page-number?: reader question or request for clarification
This page was updated March 13, 2003.
UNCONFIRMED errors and comments from readers:
[46] Example 3-5. /autohandler;
There are two technical errors with this code.
1) <%init> is closed with %init>, the "/" is missing from the second block.
2) As written the server throws an error (mason ver. 1.19). Variables declared in the
<%init> blocks are availible to every subsequent block *except* <%filter> blocks. In
fact <%filter> blocks only inherit global variables.
Here is the error.
Error during compilation of
/Library/WebServer/Documents/mason/weplayfaire/autohandler:
Global symbol "$path" requires explicit package name at
/Library/WebServer/Documents/mason/weplayfaire/autohandler line 89.
and the code
81 <%init>
82 (my $path = $r->uri) =~ s,/[^/]+$,,;
83 %init>
84
85 <%filter>
86 ...
87 ...
88 ...
89 s{(
]+src=\")(?!\w+:)} {$1$path/}ig;
90 %filter>