Personalization Methods Part 3, Embperl
November 20, 2000
Every good, or not so good, work of science fiction is a trilogy --
it's an immutable law of nature. Our series on web personalization,
back-ends, and Perl is no fiction, and only arguable scientific, but
a trilogy indeed. The past two installments considered first the
principles behind database-backed and cookie-fronted personalization
architectures, using databases as "long term" memory and
cookies as "short term" memory. Most recently, in PYNTK 18
we got our hands dirty with some
Perl code, authenticating
a user's login against a
database and setting a temporary
authentication cookie. Our trilogy does not end with any shocking
secrets (no, I am not your father), but riveting nonetheless is the
tale of Embperl, a Perl module used to embed Perl code inside
a server-parsed
HTML document. We'll see how Embperl
eases the burden of tying together the disparate parts of our
personalization system.
Meet the Embperl
The principle of server-parsed HTML is straightforward: rather than
simply hand over an HTML document to the client, the server first
interprets the file and executes any code therein, replacing that
code with its results and returning the final document to the client.
Just what "code" the server parses and executes depends on
the server-parsed language being used, and there are many:
PHP and
ASP being the most popular.
But why learn (or invent) a new language when we're already in love
with one: Perl! The authors of Embperl took this opportunity to create
support for embedding Perl code inside server-parsed HTML pages.
The possibilites of embedded Perl are almost infinite, and gives a
real kick in the pants to HTML coding. To be fair, Embperl is only
one embedded Perl solution -- there's also
HTML::Mason and
Apache::ASP.
Each vary in their approaches and are more or less suited to
particular situations -- in this case, obviously, we're using Embperl,
more accurately referred to as
HTML::Embperl.
Embperl is ideal for a mod_perl enabled environment, but you can also
use Embperl in more traditional CGI processes.
Embperl's web site contains detailed installation instructions and
test examples for different systems, so in the interest of getting to
the point, we direct you there and assume that your web server is
now interpreting HTML files with Embperl. One footnote: the Embperl
documentation illustrates a special filename extension -- .epl -- for
files to be Embperl-processed. The rationale is probably to avoid
processing costs of "regular" HTML files. In our example
we're coding for a site that has Embperl processing enabled site-wide,
and for that reason Embperl is configured in our Apache server to
process all .html files, rather than creating a special alternative
filename extension.
Contents:
Meet the Embperl
A Short Course in Embperl
Execute, @param, and %fdat
Cookies from the Oven
By Invitation Only: Requiring Login
User Sensitivity 101
Epilogue
The Perl You Need to Know
A Short Course in Embperl
|