Is over-writing $! a good idea?
The errno values that pfaut(++) mentions are there for a reason.
What is wrong with supplying your error message to die (or warn, or any of the Carp methods) in the normal way:
die "Custom error messages are good!" if $condition;
You don't have to include $! in your die statements, if you don't want to.
Alternatively, you can install a __DIE__ handler to override the default behaviour of die:
#!/usr/bin/perl
use strict;
use warnings;
local $SIG{__DIE__} = sub { die scalar localtime(), " " , $_[0] };
die "Argh!";
produces:
Sat Jan 25 00:40:36 2003 Argh! at ./custom_die.pl line 8.
If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
That way everyone learns.
|