in reply to Next in IF statement question!
for (my $i = 0; $i < @{$mydata}; $i++) { $account_number = $mydata->[$i]{'account_number'} || ''; .... if($email eq '') { bad_email("No email address found '$account_number'."); next; } ... if(($name eq '') || ($account_number eq '')) { $msg = "Missing information: Number = '$account_number', Name = '$ +name'."; next; } # Send emails send_email( send my stuff here); ... exec_single_sql($sql, $db) || die "Unable to update table"; }
This is giving you less indentation and you don't have to worry about covering error cases in end code (email, SQL).
On the other hand, I've read Dijkstra arguing that multiple exit/repeat points make it more difficult to comprehend and analyse the loop.
-- Roman
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Next in IF statement question!
by pemungkah (Priest) on Nov 17, 2010 at 00:04 UTC |