Someone complained about not being able to use "fatalsToBrowser", so here is a quick cut-n-paste way of getting both:
{ my( $warn, @warns ); BEGIN { $warn= sub { my( $head, $tail )= ( @_, "", "" ); if( @warns ) { print "\n$head<p>Warnings:<pre>\n", @warns, "</pre></p>$tail\n"; @warns= (); } }; $SIG{__WARN__}= sub { push @warns, $_[0]; }; $SIG{__DIE__}= sub { print "Content-Type: text/html\r\n\r\n", "<html><head><title>Fatal error</title>\n", "</head><body>"; &$warn(); print "<p>Died because:\n<pre>$_[0]</pre></p>", "</body></html>\n"; exit 0; }; } END { &$warn( "<html>", "</html>" ); } }
Note that this breaks eval like old versions of CGI::Carp, so install a good version of CGI::Carp to fix that problem. (:
- tye (but my friends call me "Tye")In reply to (tye)Re: warningsToBrowser
by tye
in thread warningsToBrowser
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |