Ask perl if a given scalar looks like a number (requires
Inline::C).
Inspired by Slaven Rezic's "Include Perl_looks_like_number in Scalar::Util?" post to p5p.
Hopefully this function, or something very similar to it, should be making it into Scalar::Util per the p5p thread.
update: changed the title (was Is it a number?) as it was a little ambiguous in relation to the code
use Inline C;
my $var = shift;
print +(isnum($var) ? "is a number" : "not a number"), ": $var", $/;
__END__
__C__
int isnum(SV* val) {
return Perl_looks_like_number(val);
}