in reply to Re: Better assignment to Hash of Arrays
in thread Better assignment to Hash of Arrays

I think I might be inclined to an oH instead of an oA:
>perl -wMstrict -le "my @class = ( 40, 40, 40, 183, 183, 259, 244, 503); my @qty = (260, 234, 211, 301, 401, 321, 210, 451); my %bin = map { $_ => { class => 0, qty => 0 } } 0, 40, 183, 503, 442, 259, 244 ; for my $i (0 .. $#class) { $bin{ $class[$i] }{class}++; $bin{ $class[$i] }{qty} += $qty[$i]; } for my $key (sort { $a <=> $b } keys %bin) { printf qq{%4d => [%2d, %4d] \n}, $key, @{ $bin{$key} }{ qw(class qty) }; } " 0 => [ 0, 0] 40 => [ 3, 705] 183 => [ 2, 702] 244 => [ 1, 210] 259 => [ 1, 321] 442 => [ 0, 0] 503 => [ 1, 451]