The app walks through a database, pulling "active" rows (rows needing work). It pulls some related info, does a computation, then passes the CDBI objects off to TT
for rendering as an output file. As the file is large, rather than pass a big array of Foo to TT, each is passed one by one, and TT appends the result to an open file handle.
Apologies for the obfu names in the code. Here's the loop that does all the work and takes all the time:
# obfu'd code, with some addntl comments
# NB: there are many many of these
my $it = Zmain::Foo->search( client => $client, status => 'active' );
while ( my $Foo = $it->next ) {
# NB this is a master table of Things. A Foo is a specific kind of Th
+ing. The master Thing table keeps ids and common info straight.
my $thing = Zmain::Thing->retrieve($Foo->Foo);
# NB not sure if this assert wastes time stringifying thing for the fa
+ilure message if the assertion passes?
assert( $thing, "found thing=" . $thing->thing );
my $info = $Foo->Bar->info;
my $computed = $tm->compute( $info, $thing );
$tt->process(
'template.tt',
{ Foo => $Foo, computed => $computed },
# just handle one at a time
sub { print $fh shift }
);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.