my %totals; for my $r (@$res) { $totals{ $r->{AcNo}}{$r->{Type} } = $r->{SUM}; }