use strict; use warnings; use Data::Dump; my %hash1 = ( a => 1, b => 2, c => 3, ); my %hash2 = ( b => 4, e => 5, f => 6, c => 7, ); my %intersection; for my $key (keys %hash1) { $intersection{$key} = [ $hash1{$key}, $hash2{$key} ] if exists $hash2{$key}; } dd \%intersection; #### 18:00 >perl 1527_SoPW.pl { b => [2, 4], c => [3, 7] } 18:01 >