Assuming you're parsing log files (naturally sorted in order by time), I'd suggest something like this:
my ($prevDateHour,%curHour); while (<>) { my ($dateHour, $usrMac, $apMac) = parsit(); if ($dateHour ne $prevDateHour) { for my $ap (sort keys %curHour) { print $prevDateHour, $ap, scalar(keys %{$curHour{$ap}}), " +\n"; } %curHour=(); $prevDateHour = $dateHour; } $curHour{$apMac}{$usrMac} = 1; }
(If they're not sorted, or you have multiple files, merge/sort them into a single file first.) This solution will work no matter *how* many hours your days have. ;^D
Update: Tweaked code a little (reset curHour, prevDateHour so reporting could work correctly).
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Array of Hashes of Arrays with Counts of Unique Elements
by roboticus
in thread Array of Hashes of Arrays with Counts of Unique Elements
by jcrush
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |