Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: read a file twice...

by wardk (Deacon)
on Apr 15, 2002 at 17:36 UTC ( #159277=note: print w/replies, xml ) Need Help??


in reply to read a file twice...

This sort of issue comes up alot in my shop with generating log files, typically for a scheduled "batch" job. the logfile for usability purposes needs the totals, stats, etc at the top of the log with any detail info after.

To avoid processing twice (it's usually processing a SQL cursor, but occasionally a flat file too), we typically use the method mentioned by thor.... read the file once, saving the lines to be printed afterward in one or more arrays, then pushing them out at the end.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://159277]
help
Chatterbox?
[marioroy]: The MCE::Hobo::Pool module will come later.
[Corion]: marioroy: Oh, that's always cool, having API-compatible modules. This makes testing and comparing things much easier
[marioroy]: IPC in MCE::Shared can handle 400k (sends) per second. That's seems a lot for being a pure-Perl module. After making the release, will come back and post a solution for a node by a fellow wanting faster logging.
[Corion]: While working on WWW::Mechanize:: Chrome, I had the suspicion that AnyEvent was doing something wrong, but I was able to swap it out for Mojolicious and the error persisted.
[Corion]: Of course, the error was in my own code ;)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-05-26 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?