in reply to Bring back the smartmatch operator (but with sane semantics this time)!
A lot of the discussion so far has hinged on how to tell strings from numbers (eq vs. ==), so I'm surprised no-one has mentioned Scalar::Util's looks_like_number() yet... the only downsides I see so far are that it might not be as fast as some other heuristic, and that sometimes I might want to actually compare two numbers as strings explicitly. (Okay one more... looks_like_number recognizes a few strings as numbers, such as "Inf", "Infinity", "NaN" and "0 but true". And it doesn't recognize "1_000" as a number... hmmm. See Perl_grok_number() in numeric.c)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bring back the smartmatch operator (but with sane semantics this time)!
by tobyink (Canon) on Jun 11, 2014 at 20:56 UTC | |
by Anonymous Monk on Jun 12, 2014 at 22:14 UTC |