`sub is_numeric {
($_[0] & ~ $_[0]) eq "0";
}
`
Which tests whether a scalar is a numeric value or a string value e.g `42` vs `"42"`. Whereas the snippet discerns whether a given scalar looks like a number or not e.g
`print +(isnum($_) ? "is a number" : "not a number"), ": $_", $/
for qw( 1 2.2 3e3 4. .5);
__output__
is a number: 1
is a number: 2.2
is a number: 3e3
is a number: 4.
is a number: .5
`
HTH
`_________`
__broquaint__ |
Comment onDoes it look like a number?DownloadCode