I would suggest making an hash from one array and testing that against the other (its a lot faster than what i could figure out with arrays).
# @array1 and @array2 are what are tested
my %test;
map {$test{$_}=undef} @array1;
my @result;
foreach (@array2) {
push (@result,$_) if (exists($test{$_}));
}