O(1) memory solution (provided the results are grouped by stamp):
my $last; my $count = 0; while (my $row = $sth->fetch()) { my ($stamp, $status) = @_; if (defined($last) && $last ne $status) { print("$last: $count\n"); $count = 0; } $last = $stamp; ++$count if $status eq 'In Use'; } print("$last: $count\n") if defined($last);
In reply to Re: Creating a hash of arrays from DB results (no memory)
by ikegami
in thread Creating a hash of arrays from DB results
by blaze
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |