in reply to Re: How a for() assignment works
in thread How a for() assignment works

Yes - I consider it uncouth.

"map" (and "grep") return lists. If you are not using the returned values, and merely looping, you should use "for".

     "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

Replies are listed 'Best First'.
Re^3: How a for() assignment works
by Argel (Prior) on Mar 07, 2008 at 20:27 UTC
    Your use of "uncouth" seems a bit harsh, especially given that FYI, starting with Perl 5.8.1 "map" no longer returns anything when called in void context. See Perl 5.8.1 Miscellaneous-Enhancements for more.

    Update: Sorry about that NetWallah. I missed it in the OP due to the poor formatting. Thanks for pointing it out! I will strike out that portion of my message (and bold the updates).

      "uncouth" was the language used in the O.P's post.

      Thanks for the update on the "map" update. Even with that in mind, I'm sure most programmers would agree that "for" is preferable when the return value is unused, since that usage is better understood, and you do not need to look around to verify that the context is indeed void.

      "map", for me, immediately brings into question what is being done with the returned value.

           "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

        I tend to use for as well. On the other hand, map is one of those really useful features in Perl so maybe trying to use it more often so I get more used to it is a good idea.