use CGI::Carp 'fatalsToBrowser'; # at the top of your script ... open(my $RESULTS_FILE...) or die "Error opening results file: param $returned_param, data $data, error $!\n";