Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Just wrote the following; need to work on it more but it's starting to look good and it's hella' fast. I need to get this plack thing figured out so I can stick them together.
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` <aXML> <head> <title>[stash]->{'site_title'}[/]</title> </head> <body> <h1>[stash]->{'site_title'}[/]</h1> (test)(/)<br/> (test)(/) () bracket commands don't cache and <br/> (test)(/) run every time they are called <br/> <test></><br/> <test></> <> bracket commands do cache and retain<br/> <test></> their value once computed <br/> [aXML_cache]->{'test'}[/] <br><br> [] bracket commands interpolate values<br/> in [bob][/] and hashrefs<br/> <br><p> believe it or not just those tags are all you need template<br/> wise. Logic should be in modules, not the templates!</p> <p>aXML2 is far less expressive than aXML, but far faster.<br/> The aXML code gets filtered into raw perl commands then <br/> compiled and executed by Eval::Compile resulting in<br/> performance not far short of executing plain perl.</p> <p>One notable loss for the sake of performance is the<br/> ability to build complex declarations from groups of<br/> simple ones. I am hoping to bring some of that flexibility<br/> back as I work on the filter more. Since the code is only<br/> filtered once on the child process startup, performance<br/> should remain high.</p> (aXML::Bench::EndReport)(/) </body> </aXML> `;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@<aXML>@print qq`Content-type: text\/html\n\n<html>@gs; s@<\/aXML>@<\/html>`;@gs; s@\(([^\(]+?)\)([^\(]*?)\(\/\)@`; print &$1($2); print qq`@gs; s@\[([^\[]+?)\]([^\[]*?)\[\/\]@\$$1$2@gs; s@<perl>@\@;@s; s@</perl>@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;

In reply to Re^6: source filtering and mod_perl2 by Logicus
in thread source filtering and mod_perl2 by Logicus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found