excellent Storable module is used for storing sessions. I
owe him much, as Storable is usefull in a lot of other
modules.
Perl itself and the above modules are available from any CPAN mirror,
for example
ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module
Note that you don't need to install these manually, the CPAN module will
help you. See the the section on "Automatic Installation" below.
Automatic Installation
Installing this module (and the prerequisites from above) is quite
simple, if you have the CPAN module available and network access, you
might try an automatic installation:
perl -MCPAN -e shell
If the CPAN prompt appears, asking you for commands, enter
install Bundle::HTML::EP
Automatic installation typically doesn't work on Windows, due to a
missing C development environment. However, you might try
ppm install http://www.cpan.org/authors/id/J/JW/JWIED/HTML-EP.ppd
Manual Installation
If automatic installation doesn't work, you just fetch the archive,
extract it with
gzip -cd HTML-EP-0.1125.tar.gz | tar xf -
(this is for Unix users, Windows users would prefer WinZip or something
similar) and then enter the following:
cd HTML-EP-0.1125
perl Makefile.PL
make
make test
If any tests fail, let me know. Otherwise go on with
make install
This will put the required Perl modules into a destination where Perl
finds it by default. Additionally it will install a single CGI binary,
called `ep.cgi'.
The docs are available online with
perldoc HTML::EP
If you prefer an HTML version of the docs, try
pod2html lib/HTML/EP.pm
in the source directory.
Using the CGI binary
You have different options for integrating EP into your WWW server,
depending on which server you are using and the permissions you have.
The simplest possibility is running an external CGI binary. Another
option is to use mod_perl with Apache, see the section on "Using
mod_perl" below.
I suggest that you choose an extension and configure your WWW server for
feeding files with this extension into `ep.cgi'. For example, with
Apache, you can add the following lines to your `srm.conf':
ScriptAlias /cgi-bin/ep.cgi /usr/bin/ep.cgi
AddType x-ep-script .ep
Action x-ep-script /cgi-bin/ep.cgi
This tells Apache that files with extension ep.cgi are handled by the
CGI binary `/usr/bin/ep.cgi'. On Windows, you should replace ep.cgi with
ep.cgi.bat. Make sure, that the ScriptAlias line is entered *before* any
other ScriptAlias instruction! In particular, the following would be
wrong:
ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/
...
ScriptAlias /cgi-bin/ep.cgi /usr/bin/ep.cgi
The first rule would be applied before our rule, so that it could never
match.
From now on your server will never return files with extension .ep
directly! Verify your installation by creating the following file:
Local time
The current time is:
scalar(localtime(time))
(Note that this is a much shorter version of the example in the
synopsis.) Store it as `/test.ep' on your web server and retrieve the
file via your Web server. If you see the time displayed, you are up and
running.
Using mod_perl
The EP package can be integrated into mod_perl, for example by using the
following commands in `srm.conf':
PerlModule Apache::EP
SetHandler perl-script
PerlHandler Apache::EP->handler
Options ExecCGI
Keep in mind, that mod_perl differs in many details from programming CGI
binaries. In particular you might need to restart Apache for loading
changes in modules.
Using the Internet Information Server
I am sure there is a better way of installation, in the sense of
mod_perl, however, I am no IIS expert. I can only recommend using Perl
as an external binary, in the sense of CGI.
The idea is to advice the IIS, that files with extension .ep have to be
executed by running
C:\Perl\bin\perl.exe c:\Perl\bin\ep.cgi %s%s
with %s%s being the path to the EP document. (Of course the paths have
to be adjusted to your local Perl.) This can be done by creating a new
extension in the window "Base directory/Configure". (Window name
translated from the german IIS, itīs "Basisverzeichnis / Konfigurieren"
here and might be different in english.)
Available methods
All EP tags are starting with the prefix *ep-*. Some available tags are:
ep-comment
This is a multi-line tag for embedding comments into your HTML page.
But why use this tag, instead of the usual HTML comment, `
This is another comment, but you won't see it
in your browser. The HTML editor will show it
to you, however!
Do not try to embed EP instructions into the comment section! They
won't produce output, but they might be executed anyways.
ep-perl
This is for embedding Perl into your script. There are two versions
of it: A multiline version is for embedding the Perl code
immediately into your script. Example:
The Date
The Date
Hello, today its the
# This little piece of Perl code will be executed
# while scanning the page.
#
# Let's calculate the date!
#
my($sec,$min,$hour,$mday,$mon,$year)
= localtime(time);
# Leave a string with the date as result. Will be
# inserted into the HTML stream:
sprintf("%02d.%02d.%04d", $mday, $mon+1, $year+1900);
If you don't like to embed Perl code, you may store it into a
different file. That's what the single-line version of ep-perl is
for:
The Date
The Date
Hello, today its the
You have noticed, that the little script's result was inserted into
the HTML page, did you? It did return a date, in other words a
string consisting of letters, digits and dots. There's no problem
with inserting such a string into an HTML stream.
But that's not always the case! Say you have a string like
Use