my %h4; foreach my $commonKey ( keys %h1 ) { next unless exists $h2{ $commonKey } && exists $h3{ $commonKey }; $h4{ $commonKey } = [ $h1{ $commonKey }, $h2{ $commonKey }, $h3{ $commonKey } ]; }