in reply to Re^3: why not listed foreach and if?
in thread why not listed foreach and if?
And the very next part of that sentence then reads "and composes a list of the results of each such evaluation." It's not for general purpose iteration.
Also quoth Perl Best Practices (Chapter 6):
This function [map] is specifically aimed at those situations when you want to process a list of values, to create some kind of related list.
In fact for a while (until 5.8-ish? looks like) there actually was a performance hit for (bad) code misusing map because the return value wasn't optimized away in void context so you'd pay to make the list of transformed values even though they weren't used.. Use for (or foreach or while) for general iteration, use map for transformation, or grep for filtering; otherwise you're misleading readers about what code is doing.
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|