#!perl
for $invalue (qw/ 1 -10 abc /) {
eval{ local $^W = 1; $invalue + 0 }; ### Is Number?
if ( $@ ) {
print "$invalue is *not* a Number; Details: $@\n";
} else {
print = "$invalue appears to be a number.\n";
}
}
####
1 appears to be a number.
-10 appears to be a number.
Argument "abc" isn't numeric in add at num.pl line 3.
abc appears to be a number.
##
##
#!perl
for $invalue (qw/ 1 -10 abc /) {
eval{ local $SIG{__WARN__} = sub { die @_ };
local $^W = 1; () = $invalue + 0 }; ### Is Number?
if ( $@ ) {
print "$invalue is *not* a Number; Details: $@\n";
} else {
print "$invalue appears to be a number.\n";
}
}
##
##
1 appears to be a number.
-10 appears to be a number.
abc is *not* a Number; Details: Argument "abc" isn't numeric in add at num.pl line 4.