Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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;


In reply to Re: html::template and large files by gryphon
in thread html::template and large files by xmerlin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found