Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Get out of "For Loop"!

by ikegami (Patriarch)
on Oct 12, 2010 at 22:59 UTC ( [id://864970]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^5: Get out of "For Loop"!
by Limbic~Region (Chancellor) on Oct 12, 2010 at 23:45 UTC
    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 interpreted what NetWallah wrote as assuming the OP might want to do something more than what was posted

      Me too. Why skip entries with no emails if you're not going to use the emails?

      I could see

      my @emails = map { $_->{email} eq '' ? () : $_->{email} } @$data;
      although it might be clearer to do
      my @emails = grep $_, map $_->{email}, @$data;
      I just saw these updates. Thanks for coming to my defense!

      The strange thing is - when I read chromatic's question, and re-read my code a day later, I did have to re-think for a minute about why I used map instead of grep. You were spot-on.

           Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://864970]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-18 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found