HTML-Embperl
view release on metacpan or search on metacpan
Embperl.pod view on Meta::CPAN
option in a menu. If so, this option will be pre-selected.
Example:
<FORM METHOD="POST">
<P>Select Tag</P>
If you request this document with list.htm?SEL1=x
you can specify that the element which has a value
of x is initially selected
<P><SELECT NAME="SEL1">
<OPTION VALUE="[+ $v[$row] +]">
[+ $k[$row] +]
</OPTION>
</SELECT></P>
</FORM>
=item B<INPUT>
The INPUT tag interacts with the hashes C<%idat> and C<%fdat>. If the
input tag has no value and a key exists with the same text as the
NAME attribute of the input tag, Embperl will generate a VALUE
attribute with the corresponding value of the hash key.
All values of <INPUT> tags are stored in the hash C<%idat>, with NAME
as the hash key and VALUE as the hash value. Special processing is
done for TYPE=RADIO and TYPE=CHECKBOX. If the VALUE attribute
contains the same text as the value of the hash the CHECKED attribute
is inserted, else it is removed.
So, if you specify, as the ACTION URL,
the file which contains the form itself, the form will be redisplayed
with same values as entered the first time. (See eg/x/neu.htm for an
example.)
=item B<TEXTAREA>, B</TEXTAREA>
The C<TEXTAREA> tag is treated exactly like other input fields.
=item B<META HTTP-EQUIV=>
<meta http-equiv= ... > will over-ride the corresponding http header.
This keeps Netscape from asking the user to reload the document
when the content-type differs between the http header and the
meta http-equiv.
This can also be used to set http headers. When running under mod_perl
http-headers can also be set by the function B<header_out>
Example of how to set a http header:
<META HTTP-EQUIV="Language" CONTENT="DE">
This is the same as using the Apache function
[- $req_rec -> header_out("Language" => "DE"); -]
=item B<A>, B<EMBED>, B<IMG>, B<IFRAME>, B<FRAME>, B<LAYER>
The output of perl blocks inside the C<HREF> attribute of the C<A> Tags and the
C<SRC> attribute of the other Tags are URL escaped instead of HTML escaped.
(see also L<$escmode>). Also, when inside such a URL, I<Embperl> expands array and hash references
to URL parameter syntax. Example:
[-
$A = { A => 1, B => 2 } ; # Hashreference
@A = (X, 9, Y, 8, Z, 7)
-]
<A HREF="http://localhost/tests?[+ $A +]">
<A HREF="http://localhost/tests?[+ \@A +]">
is expanded by I<Embperl> to
<A HREF="http://localhost/tests?A=1&B=2">
<A HREF="http://localhost/tests?X=9&Y=8&Z=7">
=back
=head1 Variable scope and cleanup
The scope of a variable declared with B<my> or B<local> ends at the
end of the enclosing [+/- ... -/+] block; the [+/- ... -/+] blocks act
much like Perl's { ... } in that regard.
Global variables (everything not declared with B<my> or B<local>) will
be undef'ed at the end of each request, so you don't need to worry
about any old variables laying around and causing suspicious results.
This is only done for variables in the package the code is eval'ed in --
every variable that does not have an explicit package name. All
variables with an explicit package name (i.e., in modules you use)
will stay valid until the httpd child process dies. Embperl will
change the current package to a unique name for every document, so the
influence between different documents is kept to a minimum. You can
set the name of the package with B<EMBPERL_PACKAGE>. (See also
L<"(Safe-)Namespaces and opcode restrictions">.)
Since a CGI script is always a process of its own, you don't need to
worry about that when you use Embperl as a CGI script.
If you need to declare variables which need to live longer than just one
HTTP request (for example, a database handle), you must either put it's
name in the hash C<%CLEANUP> or declare them in
another package (i.e., $Persistent::handle instead of $handle).
If you want to use the strict pragma, you can do this by using the B<var> metacommand to
declare your variables.
C<NOTE:> Bacause Apache::DBI has its own namespace, this module will
work together with Embperl to maintain your persistent database
connection.
You can disable the automatic cleanup of global variables with
B<EMBPERL_OPTIONS> or the B<cleanup> parameter of the B<Execute>
function.
Embperl.pod view on Meta::CPAN
End when $maxrow rows have been displayed.
=back
B<end of row>
=over 4
=item B<$tabmode = 16>
End table column looping when any one of the expressions in the table column
using $col returns undefined.
The column
containing the undefined expression is B<not> displayed. Only those
expressions are observed which contain an access to the variable $col.
=item B<$tabmode = 32>
End when an expression with $col becomes undefined. The column
containing the undefined expression B<is> displayed.
=item B<$tabmode = 64>
End when $maxcol columns have been displayed.
=back
The default is B<17>, which is correct for all sort of arrays. You
should rarely need to change it. The two values can be added
together.
=head2 $escmode
Turn HTML and URL escaping on and off. The default is on ($escmode =
3).
B<NOTE:> Normaly you can disable escaping by preceeding the item that
normaly is escaped with a backslash. While this is a handy thing, it could
be very dangerous in situations, where content that is inserted by some
user is redisplayed, because they can enter arbitary HTML and preceed them
with a backslash to avoid correct escaping when their input is redisplayed
again. To avoid this problem, add 4 to the values below. This will cause
Embperl to ignore the backslash when it does output escaping at all.
(only 1.3b4 and above)
B<NOTE 2:> If you want to output binary data, you must set the escmode
to zero. (only 1.3b6 and above)
=over 4
=item B<$escmode = 8 (or 15)> (2.0b4 and above)
The result of a Perl expression is always XML-escaped (e.g., `>'
becomes `>' and ' become ').
=item B<$escmode = 3 (or 7)>
The result of a Perl expression is HTML-escaped (e.g., `>' becomes
`>') in normal text and URL-escaped (e.g., `&' becomes `%26')
within of C<A>, C<EMBED>, C<IMG>, C<IFRAME>, C<FRAME> and C<LAYER> tags.
=item B<$escmode = 2 (or 6)>
The result of a Perl expression is always URL-escaped (e.g., `&'
becomes `%26').
=item B<$escmode = 1 (or 5)>
The result of a Perl expression is always HTML-escaped (e.g., `>'
becomes `>').
=item B<$escmode = 0>
No escaping takes place.
=back
=head2 $req_rec
This variable is only available when running under control of
mod_perl. It contains the request record needed to access the Apache
server API. See B<perldoc Apache> for more information.
=head2 LOG
This is the filehandle of the Embperl logfile. By writing `print LOG
"something"' you can add lines to the logfile. NOTE: The logfile line
should always start with the pid of the current process and continue
with a four-character signature delimited by a ':', which specifies
the log reason.
Example: print LOG "[$$]ABCD: your text\n" ;
If you are writing a module for use under Embperl you can say
tie *LOG, 'HTML::Embperl::Log';
to get a handle by which you can write to the Embperl logfile.
=head2 OUT
This filehandle is tied to Embperl's output stream. Printing to it has the same effect
as using the [+ ... +] block. (See also L<optRedirectStdout|"EMBPERL_OPTIONS">)
=head2 @param
Will be setup by the B<'param'> parameter of the B<Execute> function. Could be used
to pass parameters to an Embperl document and back. (see
L<Execute|"By calling HTML::Embperl::Execute">
for further docs)
=head2 %http_headers_out (only 1.2b10 and above)
You can put any http headers you want to send into this hash. If you set a location header,
Embperl will automaticly set the status to 301 (Redirect). Example:
[- $http_headers_out{'Location'} = "http://www.ecos.de/embperl/" -]
( run in 1.128 second using v1.01-cache-2.11-cpan-71847e10f99 )