my @meata = ...; my %cat; for my $meat ( @meata ){ my( $type, $id, $name ) = @{$meat}{qw/ type id name/}; $cat{ $type }{ $id } = $name; }