in reply to comparing two array
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing two array
by davorg (Chancellor) on Jun 17, 2009 at 13:29 UTC | |
|
Re^2: comparing two array
by Crian (Curate) on Jun 17, 2009 at 12:37 UTC | |
by JavaFan (Canon) on Jun 17, 2009 at 12:42 UTC | |
by citromatik (Curate) on Jun 17, 2009 at 12:54 UTC |