Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
There's more than one way to do things
 
PerlMonks  

Re: When would you choose foreach instead of map?

by Abigail-II (Bishop)
on May 20, 2004 at 20:22 UTC ( [id://355139]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to When would you choose foreach instead of map?

In this case, there isn't a technical reason to use one over the other. In both cases, you are interested in the side-effect. So, in such case, I use map if I want to put focus on the operation, and I use foreach if I want to put focus on the data being operated on. Unless I anticipate a possible change in the code in which there will be a clear preference to use one over the other - in that case, I use that one.

Abigail

  • Comment on Re: When would you choose foreach instead of map?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://355139]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.