#!/usr/bin/perl -T use strict; use warnings; use CGI qw( -headers_once ); use CGI::Carp qw( fatalsToBrowser ); my $q; # The CGI object will get file scope. BEGIN { $q = new CGI; # Construct the CGI object # within the BEGIN block. sub carp_error { my $error_message = shift; print $q->header( "text/html" ), $q->start_html( "Error" ), $q->h1( "Error" ), $q->p( "Sorry, the following error occurred: " ), $q->p( $q->i( $error_message ) ), $q->end_html; } CGI::Carp::set_message( \&carp_error ); }