http://www.perlmonks.org?node_id=522499

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>