NAME
SYNOPSYS
run in the automatically
using in the script
DESCRIPTION
mod_perl2
CGI
Wrapper
TIMEOUT
mod_perl2
CGI
Wrapper
INTERNAL METHODS
BASIC METHODS
ep
new
flush
COMPATIBLE METHODS
header_out
content_type
print
OTHER METHODS
mod_perl2
EXPORTS
OPTIONS
COMMENTS
BETA Features
Boolean Expression
Extract Array
Extract Hash
AUTHOR
COPYRIGHT
LISENCE
HTML::EmbeddedPerl - The Perl embeddings for HTML.
automatic.
passing of instanced object $ep.
that are reference of Apache::RequestRec(modperl) or __PACKAGE__(cgi).
example of use in the code tags.
# set output header ($key,$value)
$ep->header_out('Content-Create','foo');
# set of contents type, default is 'text/html', output forcing.
$ep->content_type('text/plain');
if you want not use of global variables, please use $ev.
destruct $ev after execute.
but it can use between multiple tags too.
$htm = something;
use HTML::EmbeddedPerl;
$e = HTML::EmbeddedPerl->new();
# set output header ($key,$value)
$e->header_out('Content-Create','foo');
# set of contents type, default is 'text/html'
$e->content_type('text/plain');
# flushing header and contents. (example 1)
$e->ep(\$htm);
# not flushing header, return contents to $r.
$r = $e->ep(\$htm);
# flushing HTTP header.
$e->flush;
# same above. (example 1)
print $r;
The Perl-Code embeddings for HTML, it is simple and easy.
adding <$ Perl-Code $> to your HTML.
write httpd.conf or .htaccess.
<FilesMatch ".*\.phtml?$">
# Output Mode - 0..5, see OPTIONS section.
PerlSetEnv OUTMODE 0
SetHandler modperl
PerlResponseHandler HTML::EmbeddedPerl
PerlOptions +ParseHeaders
</FilesMatch>
needs most compatibility, use PerlResponseHandler perl-script.
inserting first line to
#!/your/path/twepl
if you cannot use twepl? but wrapper.pl is available.
write .htaccess.
AddType application/x-embedded-perl .phtml
AddHandler application/x-embedded-perl .phtml
Action application/x-embedded-perl /your/path/wrapper
force exiting over the timeout for loop detection.
$TIMEOUT is global, please change it overwritten.
# default is "2" seconds.
$TIMEOUT = 2;
already executing under alarm, cannot change that timeout.
# set as new timeout.
alarm(X);
# cancelling timeout.
alarm(0);
# set as new timeout.
alarm(($TIMEOUT=X));
# cancelling timeout and unset timeout.
alarm(($TIMEOUT=0));
# set as new timeout.
alarm(X);
before calling sub ep()
$HTML::EmbeddedPerl::TIMEOUT = X;
_coloring
_extract_hash
_extract_array
_init
_run
handler
ep($string,$option);
$ep = HTML::EmbeddedPerl->new();
flushing HTTP header.
$ep->flush;
it tiny-tiny solving cgi-modperl compatibility methods.
use that $ep->method *inner code tags only.
$ep->header_out($key,$val);
$ep->content-type($type);
$ep->print($string);
other methods define it freely.
depends Apache::RequestRec and more.
ep(string,option)
0 = default, execute only once.
1 =-- with coloring source.
2 = older version compatible, every tags every execute.
3 =-- with coloring source.
4 = output internal code.
5 =-- with coloring source.
# comments
// comments
/* comments */
recommended use /* */ and please do not put comments in the same line as the code if possible.
case of extract scalar in non-code blocks.
<$ my $scalar = 'this is scalar'; $>
<p>$scalar</p>
...
<p>this is scalar</p>
if you want not extract vars, please use escape sequence '\'.
<p>\$scalar</p>
...
<p>$scalar</p>
and available simple template.
<!=EXPRESSION>...</!>
replace inner <!> to else, <!=EXPRESSION> to elsif.
<$ my $flag = 1; my $oops = 'oops!'; $>
<!=$flag><p>$flag</p><!><p>$oops</p></!>
...
<p>1</p>
> is same a tag-close, try ($a > $b) in compilation errors.
<@=ARRAYNAME>...</@>, extract value is $_.
ARRAYNAME can use reference {ARRAYNAME} or \ARRAYNAME.
$n = current array name.
$i = current position.
$c = equals scalar @array;
and $XXX = want vars.
<$ my @array = ('a'..'c'); $>
<@=array><p>$i: $_</p>\n</@>
...
<p>0: a</p>
<p>1: b</p>
<p>2: c</p>
<%=HASHNAME>...</%>, extract key is $k, value is $v.
HASHNAME can use reference {HASHNAME} or \HASHNAME.
$n = current hash name.
$c = equals scalar keys %hash;
and $XXX = want vars.
<$ my %hash = ('a'=>1,'b'=>2,'c'=>3); $>
<table>
<%=hash><tr><th>$k</th><td>$v</td></tr>\n</%>
</table>
...
<table>
<tr><th>a</th><td>1</td><tr>
<tr><th>b</th><td>2</td><tr>
<tr><th>c</th><td>3</td><tr>
</table>
Twinkle Computing <twinkle@cpan.org>
Copyright (c) 2010 Twinkle Computing All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.