in reply to Get out of "For Loop"!

Only if you don't want to process the rest of the items in @$data. I suspect you really want to use next instead of last so you can advance to the next one.

Further, that's a rather C-ish loop. Might I suggest something like this:

for my $item (@$data) { if (defined($$item{email}) and $$item{email} ne '') { good("Email found."); } else { bad("No email address."); next; } ...other stuff... }

...roboticus

Replies are listed 'Best First'.
Re^2: Get out of "For Loop"!
by ikegami (Patriarch) on Oct 12, 2010 at 18:51 UTC
    There's no reason to separate the error check from the error message in this code.
    for my $item (@$data) { if (!defined($item->{email}) || $item->{email} eq '') { bad("No email address."); next; } good("Email found."); ...other stuff... }
        Your code is correct, just structurally more complicated than it needed to be.