my (%a1, %a2); undef @a1{@a1}; undef @a2{@a2}; my @in_both = grep { exists $a1{$_} } keys %a2;