#!/usr/bin/perl BEGIN { $|++; print "Content-type: text/html\n\n"; # this may also help as it will capture STDERR in the browser open STDERR, ">&STDOUT"; use CGI::Carp 'fatalsToBrowser'; } print STDERR "
Foo
"; print STDOUT "Bar
"; # catches almost all errors one way or another # if ( $syntax_error ) { END { print STDERR "Exiting!" }