=pod
=head1 NAME
HTML::Embperl - Perl extension for embedding Perl code in HTML documents
=head1 SYNOPSIS
Embperl is a Perl extension module which gives you the power to
embed Perl code directly in your HTML documents (like server-side
includes for shell commands).
=head1 DESCRIPTION
=head1 Operating-Modes
Embperl can operate in one of four modes:
=head2 Offline
Converts an HTML file with embedded Perl statements into a standard
HTML file.
B
B
Use embpexec.pl on Unix systems and embpexec.bat on Win32 systems.
=over 4
=item B
The full pathname of the HTML file which should be processed by
Embperl.
=item B
Optional. Has the same meaning as the environment variable
QUERY_STRING when invoked as a CGI script. That is, QUERY_STRING
contains everything following the first "?" in a URL.
should be URL-encoded. The default is no query string.
=item B<-o outputfile>
Optional. Gives the filename to which the output is written. The
default is stdout.
=item B<-l logfile>
Optional. Gives the filename of the logfile. The default is
/tmp/embperl.log.
=item B<-d debugflags>
Optional. Specifies the level of debugging (what is written to the
log file). The default is nothing. See L<"EMBPERL_DEBUG"> for exact values.
=back
=head2 As a CGI script
Instead of a file being sent directly by the web server, the document
is processed by the CGI script and the result is sent to the client.
B
B
Use embpcgi.pl on Unix systems and embpcgi.bat on Win32 systems.
If C is invoked without any parameters and the
environment variable B is set, it runs itself as a CGI
script. This means that form data is taken either from the
environment variable B or from stdin, depending on whether
or not B is set. (This will be set by the web server
depending on whether the request method is GET or POST). Input is
taken from the file pointed to by B and the output is
send to stdout. The logfile is generated at its default location,
which is configurable via the environment variable B.
To use this mode you must copy B to your cgi-bin
directory. You can invoke it with the URL
http://www.domain.xyz/cgi-bin/embpcgi.pl/url/of/your/document.
The /url/of/your/document will be passed to Embperl by the web server.
Normal processing (aliasing, etc.) takes place before the URI makes it
to PATH_TRANSLATED.
If you are running the Apache httpd, you can also define
B as a handler for a specific file extention or
directory.
Example of Apache C:
Action text/html /cgi-bin/embperl/embpcgi.pl
B: Out of security reasons, embpexec.pl must not be used anymore as
CGI script!
B: CGI Scripts are not so secure. You should consider using L
to restrict the access to the rights documents.
=head2 From mod_perl (Apache httpd)
This works like the CGI-Script, but with the advantage that the script
is compiled only once at server startup, where other one-time actions
(such as opening files and databases) can take place. This will
drastically reduce response times for the request. To use this you
must compile C with C and add C
as the C.
Example of Apache C or C:
SetEnv EMBPERL_DEBUG 2285
Alias /embperl /path/to/embperl/eg
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
Another possible setup is
SetEnv EMBPERL_DEBUG 2285
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
AddType text/html .epl
Don't forget the B. In this setup, all files ending with
.epl are processed by Embperl.
See the section L<"EMBPERL_DEBUG"> (dbgLogLink and EMBPERL_VIRTLOG) to find
out how you can configure Embperl so you can view the log file with
your browser!
B: When mod_perl is compiled as loadable module (i.e. with USE_DSO) you
B load Embperl at server startup time!
B: L<"perldoc EmbperlObject"|"EmbperlObject.pod"> to see how to setup I in a way to
create your site out of small overwriteable objects.
=head2 By calling HTML::Embperl::Execute (\%param)
Execute can be used to call Embperl from your own modules/scripts (for example
from a Apache::Registry or CGI script) or from within another Embperl page (only 1.2b1
or higher) to nest multiple Embperl pages (for example to store a common header or
footer in an different file).
There are two forms you can use for calling Execute. A short form which only takes an
filename and optional additional parameters or a long form which
takes a hash reference as its argument. This gives it the chance to
vary the parameters according to the job that should be done.
(See B for more detailed examples)
B: L<"perldoc EmbperlObject"|"EmbperlObject.pod"> to see how to setup I in a way to
create your site out of small overwriteable objects and L<"perldoc HTML::Embperl::Mail"|"Mail.pod"> how
to use I to send email.
Execute($filename, $p1, $p2, $pn) ;
This will cause Embperl to interpret the file with the name $filename and, if specified, pass
any additional parameters in the array @Z<>param (just like @_ in a perl subroutine).
The above example could also be written in the long form:
Execute ({inputfile => $filename,
param => [$p1, $p2, $pn]}) ;
The possible items for hash of the long form are:
=over 4
=item B
The file which should be used as source. If B is also specified,
this parameter should be given a unique name to identify the source.
Every time Embperl sees the same text in B, it assumes that
you compiled the same source - that means that Embperl uses the same package
name as in your last call, and only recompiles the code if B has
changed or is undefined.
=item B
Call the Embperl subroutine named by this parameter(see also B<"[$ sub $]">).
Currently the subroutine
must be in the same file or if it's in another file, the other file has to be
imported first.
=item B
Reference to a string which contains the source. B must also
be specified to give a name for the source. The name can be any text.
=item B
Last modification time of member B. If undef the code passed
by input is always recompiled, else the code is only recompiled if
mtime changes.
=item B
File to which the output should be written. If neither outputfile
nor output is specified, ouput is written to stdout.
=item B