good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: Check multiple array elements for a single conditionby Athanasius (Archbishop) |
on Sep 11, 2016 at 15:41 UTC ( [id://1171551]=note: print w/replies, xml ) | Need Help?? |
add the element number to the array slice, and update the equal-to count number. Whenever a single change requires two (or more) synchronised updates to the code, this is a bug waiting to happen. In this case, we can take advantage of the fact that “all x are y” is logically equivalent to “it is not the case that any x is not y.” That is, we can eliminate the duplication by negating both the condition and the if statement:
Output:
Hope that helps,
In Section
Seekers of Perl Wisdom
|
|