in reply to combining hashes based on key values

# first, determine all the id's and which sets they appear in. # presume that no id can appear more than once per set. # also initialize the (one) record per id for the result. my %by_id; my %out_rec; for my $set ( keys %in_hash ) { for ( @{ $in_hash{$set} } ) { $by_id{$_->{'id'}}{$set} = $_; %{$out_rec{$_->{'id'}}} = %$_; } } my %out_hash; for my $id ( keys %by_id ) { my @sets = sort keys %{ $by_id{$id} }; $out_rec{$id}{'score'} = 0; $out_rec{$id}{'score'} += $by_id{$id}{$_}{'score'} for @sets; push @{ $out_hash{"@sets"} }, $out_rec{$id}; } # and at this point %out_hash contains the desired data.