use CGI::Carp qw(fatalsToBrowser set_message); BEGIN { sub handle_errors { my $msg = shift; print "

Oh gosh

"; print "

Got an error: $msg

"; } set_message(\&handle_errors); }