open( my $fh, "<", $array_ip_list ) or send_mail("ip_list_error"), die "IP List File - nas_array_ip_list.txt not found"; # [ . . . Do lots of stuff here . . . ] # If our external commands completed successfully, send our e-mail if ($result_from_nas_check_function) { send_mail( "results", $filename ); # [ Clean up after ourselves, delete our temp file, etc. ] exit 0; } else { # [ Notify e-mail that an error occured ] # [ Clean up after ourselves, delete our temp file, etc. ] die "Something went wrong."; }