Just a FWIW ... here's something I've used when trying to get the browser to display error messages in situations where my access to tools is limited. I grabbed this from a list/group years ago, and don't pretend to be able to explain the finer points of what makes it tick....
#Put the following code at the top of the script, just below #!/usr/bi
+n/perl.
#Run the program from your browser, and read what is printed there.
BEGIN {
local($|) = 1; # Temporarily turn off bufferi
+ng
print "Content-type: text/plain\n\n";
my $date = localtime;
print "Script $0\nrunning on $date (Perl version $])\n\n";
unless (open STDERR, ">&STDOUT") {
print "Can't redirect STDERR: $!";
exit;
}
print "\n";
}