http://www.perlmonks.org?node_id=397369


in reply to String/Numeric Manipulation

You could trap warnings for not numerics
use warnings; my $days = 'oops'; eval { local $SIG{__WARN__} = sub { die "not numeric" }; $days += 0; }; if ($@) { # at this point $days will be zero # and $@ will be "not numeric" }