As a side-note, in general, don't use $@ to test whether an eval succeeded or failed. It's quite easy to come up with examples where an eval failed, but $@ is false, or where an eval succeeded, but $@ is true (for instance, due to actions happening at DESTROY time). Always make sure your block returns true, and test the return value of
eval: if it's undefined, the eval failed:
eval {
# make conversion failure a fatal error
use warnings FATAL => qw(numeric);
# try to use $s as a number
$number = 0 + $s;
1;
} or do {
my $err = $@ || "Unknown error";
# exception happened, thus not a number
$number = undef;
};