listing of /var/www/action.pl -------------------- #!/usr/bin/perl use Modern::Perl; use aXML2; our $stash = { site_title => "bob's bit'z emporium" }; our $bob = "scalars"; my $ctr; sub test { $ctr++; "run $ctr"; } $_ = qq` [stash]->{'site_title'}[/]

[stash]->{'site_title'}[/]

(test)(/)
(test)(/) () bracket commands don't cache and
(test)(/) run every time they are called

<> bracket commands do cache and retain
their value once computed
[aXML_cache]->{'test'}[/]

[] bracket commands interpolate values
in [bob][/] and hashrefs

believe it or not just those tags are all you need template
wise. Logic should be in modules, not the templates!

aXML2 is far less expressive than aXML, but far faster.
The aXML code gets filtered into raw perl commands then
compiled and executed by Eval::Compile resulting in
performance not far short of executing plain perl.

One notable loss for the sake of performance is the
ability to build complex declarations from groups of
simple ones. I am hoping to bring some of that flexibility
back as I work on the filter more. Since the code is only
filtered once on the child process startup, performance
should remain high.

(aXML::Bench::EndReport)(/)
`;aXML2; Listing of /etc/perl/aXML2.pm ------------------- use Modern::Perl; use Eval::Compile qw ( ceval ); use aXML::Bench; our $cache; sub aXML2 { local $_ = $_[0] ||= $_; &aXML::Bench::Start(); s/@/\@/gs; s@@print qq`Content-type: text\/html\n\n@gs; s@<\/aXML>@<\/html>`;@gs; s@\(([^\(]+?)\)([^\(]*?)\(\/\)@`; print &$1($2); print qq`@gs; s@\[([^\[]+?)\]([^\[]*?)\[\/\]@\$$1$2@gs; s@@\@;@s; s@@print qq\@@s; s@<([^<]+?)>([^<]*?)@`; \$aXML_cache->{'$1'} = &$1('$2') unless \$aXML_cache->{'$1'}; print \$aXML_cache->{'$1'}; print qq`@gs; ceval $_; } 1; Listing of /etc/perl/aXML/Bench.pm ------------------------ package aXML::Bench; use Modern::Perl; use Time::HiRes qw ( gettimeofday tv_interval ); my ($start,$end,$elapsed,$fps); sub MileStone { End(); my $report=Report(); Start(); return $report;} sub EndReport { End(); return Report(); } sub Start { $start = [ gettimeofday ]; return ""; } sub End { $end = [ gettimeofday ]; return ""; } sub Report { $end = [ gettimeofday ]; $elapsed = tv_interval($start,$end); $fps = int(1 / $elapsed); return "$elapsed = $fps p/s"; } 1;