my %present; for my $a ( \@array1, \@array2, \@array3 ) { $present{ $_ }++ for @{ $a } } my @only_two = grep $present{ $_ } == 2, keys %present;