in reply to html::template and large files
Greetings xmerlin,
In your example, you have the entire log file getting loaded into @lines all at once. If your log file is especially large, you'll run out of memory. What you probably want instead is to only look at a single line in the file at a time.
my @log; if (-e $logfile) { open(LOG, '<', $logfile) or die $!; while (<LOG>) { push @log, { logLine => $_, error => (/error/i) ? 1 : 0 }; last if (@log > $some_large_number ); } close(LOG); } $tmpl->param( log1 => \@log );
The other problem, though, is that it looks like you want to dump the entire log into a web page. With an especially large log file, that will be a problem for the client's memory and take a long time for the data transfer. You'll want to add an "if the log is bigger than n lines, stop" line inside the while.
gryphon
Whitepages.com Development Manager (DSMS)
code('Perl') || die;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: html::template and large files
by xmerlin (Initiate) on Jan 11, 2006 at 19:33 UTC | |
by gryphon (Abbot) on Jan 11, 2006 at 21:35 UTC |
In Section
Seekers of Perl Wisdom