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"; }