I usually do what sgifford says, and write my own mydie
function to replace the built-in die (which, among
other things, allows calling a function that wraps
my error message in a page that includes such things
as site headers, footers,
stylesheets, sidebars, whatever, provided said
routine does not itself call the mydie function),
but there's also CGI::Carp qw(fatalsToBrowser);
The latter is simpler and useful for development,
although I don't know that I would encourage keeping
it in production code, since it potentially could
expose to the user information you might not want
them to have, which might be a security issue.