This is a faq: How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
If what you want is to see if a scalar is in the array, you can try grep:
print +(grep {$_ eq $elem} @array) ? "Yes" : "No";
Or
my %h = map { $_ => 1 } @array; print defined $h{$elem} ? "Yes" : "No";
Update: Changed the grep regexp by eq (see the comment below from davorg)
citromatik
In reply to Re: comparing two array
by citromatik
in thread comparing two array
by paola82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |