jasonl has asked for the wisdom of the Perl Monks concerning the following question:
I'm parsing a large logfile (this is sort-of-but-not-entirely related to another question I just posted about sorting by timestamp) that has data from a bunch of different clients in it, and once a particular client hits a trigger, I need to get all data in the logfile from that client, whether it's before or after the trigger. What I'm doing currently is looping through the file twice, getting the list of clients that hit the trigger on the first pass, and then on the second pass looking for *any* lines logged by a client, like this:
%clientHash = getTrigger(\*INFILE); seek(INFILE,0,0); %leaseHash = readLog(\*INFILE, \%clientHash);
(readLog() splits each input line and looks to see if the client field from that line matches an existing key in %clientHash.) This works, but I'm wondering if there's a cleaner way to do it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: is this the most efficient way to double-parse a large file?
by hdb (Monsignor) on Jan 19, 2014 at 19:07 UTC | |
|
Re: is this the most efficient way to double-parse a large file?
by Laurent_R (Canon) on Jan 19, 2014 at 20:04 UTC | |
|
Re: is this the most efficient way to double-parse a large file?
by GrandFather (Saint) on Jan 21, 2014 at 00:49 UTC | |
by jasonl (Acolyte) on Jan 21, 2014 at 16:21 UTC | |
by GrandFather (Saint) on Jan 21, 2014 at 22:03 UTC |