ok has asked for the wisdom of the Perl Monks concerning the following question:
Since there are many log entries per second, the plan is to push each entry on to an array keyed by the unix time, then print each entry for (sort %bighash). Here's what I have:cat crap | mysort > sorted_crap
This all goes to hell when the size of crap gets real big, ie, Out of memory!. Can anyone suggest a more efficient solution?$log_entries = {}; while ( <STDIN> ) { # Date string looky like: "06/Apr/2001:08:30:05" /(\d{2}\/\w{3}\/\d{4}\:\d{2}\:\d{2}\:\d{2})/; $secs = parsedate($&); push @{$log_entries->{$secs}}, $_; } foreach $key (sort %$log_entries) { foreach $entry (@{$log_entries->{$key}}) { print $entry; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jcwren) Re: memory monster
by jcwren (Prior) on Apr 07, 2001 at 01:11 UTC | |
|
Re: memory monster
by arturo (Vicar) on Apr 07, 2001 at 01:05 UTC | |
|
Re: memory monster
by stephen (Priest) on Apr 07, 2001 at 13:16 UTC |