BEGIN { if ($@) { # This print html error code will go into a sub within # the main script. It's here for illustration purposes. print qqContent-type: text/html\n\n~; print qq~\n~; print qq~\n~; print qq~Error\n~; print qq~\n~; print qq~\n~; print qq~A fatal error has occurred blah blah...\n~; print qq~\n~; print qq~~; exit; } } #### use CGI::Carp qw(fatalsToBrowser set_message); BEGIN { sub handle_errors { my $msg = shift; print "

Oh gosh

"; print "

Got an error: Not saying much

"; } set_message(\&handle_errors); }