http://www.perlmonks.org?node_id=296806


in reply to Think for yourself.
in thread is the use of map in a void context deprecated ?

Thinking for myself, I still think that it is poor style.

What is the difference between what these lines should do?

map do_something($_), @some_list; do_something($_) for @some_list;
They should do the same thing. But to my eyes the second reads much more clearly, and I believe that the same holds true at virtually any level of Perl expertise.

If there is a clear way and an unclear way of writing the same thing, with both taking similar effort and length, I call it bad style to deliberately use the unclear one (unless confusion is your goal).

In fact the only reasons that I have seen given for why to use map (and yes, I have seen people try to recommend it) is that it is compact and demonstrates that you really know Perl. I cannot think of a worse reason to (mis)use a feature. Particularly since the goal is not achieved. Inline loops are even more compact, and are more likely to make a positive impression on good Perl programmers.

This does not, of course, justify deriding someone who has picked up the meme of map in void context. But it does indicate gently pointing out that there are clearer ways to do the same thing.