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;
-
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.
|