if ( grep { $_ eq $foobar} @array ) { }
Update: Use the above code if you really want to compare all array values (which is what you said). If you really want to just know if the value is in the array (and then stop searching), you might try the following, which might perform better in certain situations:
use List::Util qw(first); if ( first { $_ eq $foobar } @array ) { }
In reply to Re: Compare all array values without a loop
by edan
in thread Compare all array values without a loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |