in reply to Check multiple array elements for a single condition
Another example using grep. This one isn't much shorter, but where it'll help is if you have to check more elements; simply add the element number to the array slice, and update the equal-to count number.
if ((grep /^0$/, @array[0,1]) == 2){ say "both are zero"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check multiple array elements for a single condition
by Athanasius (Archbishop) on Sep 11, 2016 at 15:41 UTC |