... for (my $i = 0; $i < @{$mydata}; $i++) { $account_number = $mydata->[$i]{'account_number'} || ''; $name = $mydata->[$i]{'name'} || ''; $email = $mydata->[$i]{'email'} || ''; if($email eq '') { bad_email("No email address found '$account_number'."); next; # <------ here } elsif ($email !~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i ) { $msg = "Invalid email address - '$email' on account '$account_number'."; bad_email($msg); next; # <------ here } elsif (($name eq '') || ($account_number eq '')) { $msg = "Missing information: Number = '$account_number', Name = '$name'."; next; # <------ here } else { # Send emails send_email( send my stuff here); my $data = "