|
|
| 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 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
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||