An example format for a logline: 2010-08-10 13:59:54 GGS INFO 260 Something Something Manager for Monitor, mgr.prm: Lag for REPLICATION REP is 00:00:00 (checkpoint updated 00:00:02 ago).
The $key, in this line, would be "260" (without quotes).
The value would be the line itself, but as an array.
There could be many such "values" per $key, so the $key is not unique in this logfile. I thought a hash of arrays would fit the bill because,for each $key, there' be several lines.
An excerpt from my current attempts: my %sorted_msgs = map { $_[5], $_[0] } sort { Date_Cmp($a->[1], $b->[1]) } map { my @logline = split(/\s+/, $_, 5); my $timestring = '\'' . $logline[0] . ' ' . $logline[1] +. '\''; [ $_, ParseDate($timestring), $logline[0], $logline[1], +$logline[2], $logline[3], $logline[4] ]; } @matched_lines;
In the split, after #5, I capture the rest of the logline.
The ParseDate is from Date::Manip, and works flawlessly in other routines, so i hope that doesn't distract from the question.
The first, inner map, is where I transform the array into anther, temporary array of values that I munged and/or want to be able to access. Then I do a sort on the timestamp, and, lastly, I (am trying) to convert values in the transformed array into a hash of arrays.
Dumper shows: DUMPER: $VAR1 = 'HASH(0x82442a0) ';
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |