The stupid question is the question not asked | |
PerlMonks |
Re: in_array and skipping foreachby jdporter (Paladin) |
on Jan 16, 2020 at 16:34 UTC ( [id://11111494]=note: print w/replies, xml ) | Need Help?? |
Any ideas how I can make this better? Any will do it! Specifically, the any function from the List::Util module:
Many cases of using grep in a conditional can be written using any instead, as it can short-circuit after the first true result. Of course, a hash is better if you're going to be doing this check a lot of times.
I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
In Section
Seekers of Perl Wisdom
|
|