in reply to Re^3: comparing arrays
in thread comparing arrays

A hash slice would (I guess) be more efficient (insted of the map-statement).

my %hash; @hash{@array2};

This code will set for all the elements in @array2 the value in the hash to undef. And later on you can see if it exists by using the exists (or not exists) function (as done in your code).