Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: improve performanceby GotToBTru (Prior) |
on Jun 08, 2015 at 16:34 UTC ( [id://1129456]=note: print w/replies, xml ) | Need Help?? |
Consider if you can use the none function from List::Util for operations like (! grep ). grep will check the entire list to find all the values that match, but in this case, once you have found a match you might as well stop. Some of the List::Util functions, like first or any or none, will short circuit. In this example, the variable $j shows how many times the loop body is executed.
Output:
Update: forgot to copy the code that actually produces that output!
In Section
Seekers of Perl Wisdom
|
|