in reply to Re: Get out of "For Loop"!
in thread Get out of "For Loop"!

Why map and not grep?

Replies are listed 'Best First'.
Re^3: Get out of "For Loop"!
by Limbic~Region (Chancellor) on Oct 12, 2010 at 22:18 UTC
    chromatic,
    Why map and not grep?

    Perhaps I am missing something, but grep doesn't look reasonable here. This is both filtering and transforming which makes me think map. In addition to filtering hash references based on the 'email' key, it returning the value of the 'name' key. I can't think of a way to do that with grep that is clear but please feel free to elucidate me?

    Cheers - L~R

      There is no translation in the OP, and I suspect it's undesirable to drop the email addresses.

        ikegami,
        The node to which chromatic replied, says: I'm assuming you want to do something useful with the list of cases where there is "No email address". If so, 'map' is your friend:

        I interpreted what NetWallah wrote as assuming the OP might want to do something more than what was posted and offered a suggestion. I know chromatic is a smart guy, so if he had meant - you shouldn't be transforming here, you should just be filtering (map vs grep) then I understand the comment. But the code block as written, which I am sure NetWallah understood is most naturally written as map not grep (at least to me) is what chromatic appeared to be responding to (at least to me). That is why I asked for elucidation. Your response, which is a legitimate interpretation of comment - is not what I took away. Especially given it was so terse.

        Cheers - L~R

      I misread NetWallah's code in light of the OP's code.