in reply to Fast way to distinc number vs string from Perl level
However, I would've thought that B (once loaded) would perform the same checks just as quickly.#! perl -l use Inline C => <<'EOC'; SV * is_IV(SV * x) { /* integer */ if(SvIOK(x)) return newSVpv("yes", 0); return newSVpv("no", 0); } SV * is_NV(SV * x) { /* float */ if(SvNOK(x)) return newSVpv("yes", 0); return newSVpv("no", 0); } EOC print is_IV(1); # yes print is_IV("1"); # no
|
|---|