P is for Practical | |
PerlMonks |
Re: Answer: How can I add all the numbers in an array with out doing a foreach loop?by MidLifeXis (Monsignor) |
on Oct 21, 2013 at 13:03 UTC ( [id://1059106]=note: print w/replies, xml ) | Need Help?? |
While these will "work", they confuse the issue of what you are trying to accomplish. grep is used to select items from a list. map is used to transform one list into another. Both take one list and return another list. In my opinion, using grep or map for tasks outside of that scope is being 'too cute', and will cost time later when maintenance time comes around. It takes more work (albeit not much) to comprehend the intent of these code blocks. Make it easier on your future-self and avoid using map and grep for this purpose. --MidLifeXis
In Section
Seekers of Perl Wisdom
|
|