in reply to Cleaner build of an AoH for nested loop?
I might write it this way.
foreach my $case ( @{$all_cases} ) { if ( $case_list && $case->{examiner} eq $case_list->[-1]->{examiner} ) { push @{ $case_list->[-1]->{casedata} }, $case; } else { push @{$case_list}, { examiner => $case->{examiner}, casedata => [$case] }; } }
That eliminates all the extra variables, and you're not looping over indices instead of elements, but it seems a little longer (even though it's really fewer statements).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Cleaner build of an AoH for nested loop?
by bradcathey (Prior) on Mar 06, 2009 at 13:53 UTC | |
by kyle (Abbot) on Mar 06, 2009 at 17:44 UTC |