xmerlin has asked for the wisdom of the Perl Monks concerning the following question:
The problem:
The code below fails with out of memory if the file is too large How to solve this?
code snippet:
if (-e $logfile) { my $fh=new IO::File($logfile,'r'); @lines=$fh->getlines(); $fh->close; } my $log=[]; foreach my $l (@lines) { if ($l=~m/error/i) { push @$log,{logLine=>$l,error=>1}; } else { push @$log,{logLine=>$l}; } } $tmpl->param(log1=>$log); template snippet: <tmpl_loop name=log1> <tmpl_if name=error> <font color=red> </tmpl_if> <tmpl_var escape=html name=logLine><br> <tmpl_if name=error> </font> </tmpl_if> </tmpl_loop>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: html::template and large files
by gryphon (Abbot) on Jan 11, 2006 at 17:47 UTC | |
by xmerlin (Initiate) on Jan 11, 2006 at 19:33 UTC | |
by gryphon (Abbot) on Jan 11, 2006 at 21:35 UTC |
Back to
Seekers of Perl Wisdom