> The manual entry for die suggests using Carp, which is what I
> suggested too. Using core perl modules seems far safer ...
The "perldoc -f die" entry does not mention Carp.
Carp provides better formatting of message sent via die:
"The Carp routines are useful in your own modules because
they act like die() or warn(), but with a message which
is more likely to be useful to a user of your module."
i.e. Carp is for terminating (via croak or confess)
or warning (via carp or cluck) in a "nicer way", to be
used for the benefit of CLIENTS of the software you are writing.
You are looking at Carp instead of CGI::Carp. The latter is adapted to the task at hand (OPAC errors).
> Why aren't you using the Carp modules or something based on them?
Carp does not provide exception catching.
But CGI::Carp can, and commonly does.
The following catches fatal errors, including "die":
use CGI::Carp qw(fatalsToBrowser);
The following catches warnings, including "warn":
use CGI::Carp qw(warningsToBrowser);
The messages get formatted and datestamped as appropriate for the logs and also (optionally) displayed to the browser. I find it very useful, and it avoids the performance hit of having to defer compilation of everything to runtime evals.
Carp does not provide the functionality I have demonstrated at
http://praxis.com.au/demo_error.pl/showio
which intercepts an IO error, and displays detailed information to
the browser in addition to notifying the sysadmin.
The demo_error.pl example intercepts ALL errors and works for all
perl applications :)