foreach my $keys (keys %hash1){ if (defined $hash2{$keys}){ print @{ $hash1{$keys} }, "\t", $hash2{$keys}, "\n";