Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re: How can I add all the numbers in an array with out doing a foreach loop?
in thread How can I add all the numbers in an array with out doing a foreach loop?

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1059106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found