![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: is_numericby syphilis (Archbishop) |
on Apr 12, 2007 at 07:09 UTC ( [id://609583]=note: print w/replies, xml ) | Need Help?? |
Scalar::Util provides access to the underlying Perl API looks_like_number routine which Perl itself uses internally Perl will evaluate the string (eg) '5621hello' in numeric context as 5621 ... yet looks_like_number() will tell you that the string '5621hello' does not look like a number. That has always struck me as an anomaly .... I tend to think that a a string that "does not look like a number" should evaluate to zero in numeric context, but that (obviously) doesn't always happen. I don't think this is a big deal, btw - it's just that it doesn't DWIM (for me, anyway). Cheers, Rob Update: I meant to add that this might even have some siginificance for the op - because we can't assume anything about the numeric value of a variable, based on the fact that Scalar::Util says it doesn't look like a number.
In Section
Cool Uses for Perl
|
|