, don't you? :-)
URI is yet another of its packages, we need the URI::Escape
module.
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
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
AddHandler 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'. Make sure, that the ScriptAlias line is
entered *before* any other ScriptAlias instruction!
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, it 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.
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