use CGI::Carp qw( fatalsToBrowser ); use CGI qw( -headers_once ); my $q = new CGI; BEGIN { CGI::Carp::set_message sub { my $error = shift; $q ||= new CGI {}; # !!! print $q->header(), $q->start_html( "Error" ), $q->h1( "Error" ), $q->p( "Sorry, the following error occurred:" ), $q->pre( $q->i( $error ) ), $q->end_html(); }; }