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); }
In reply to Does it look like a number? by broquaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |