use strict; use warnings; use Data::Dump 'pp'; my %h1 = ( a => 1, b => 2, c => 3, ); my %h2 = ( a => 4, b => 5, d => 10, ); my %h3 = ( x => 20, p => 15, b => 6, a => 12, ); my %out; for my $key (keys %h1) { next unless exists $h2{$key} and exists $h3{$key}; $out{$key} = [ $h1{$key}, $h2{$key}, $h3{$key} ]; } pp \%out; __END__ { a => [1, 4, 12], b => [2, 5, 6] }