Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: Converting to number doesn't always work... (updated)by syphilis (Archbishop) |
on Nov 22, 2019 at 08:41 UTC ( [id://11109052]=note: print w/replies, xml ) | Need Help?? |
Instead of trying to trap the warning, it's better to use looks_like_number from Scalar::Util, as this gives you the exact internal function that Perl uses to check strings and generate that warning in the first place Seems that perl doesn't always issue a warning when a variable that doesn't look like a number is used in numeric context: For both of those one liners, Scalar::Util::looks_like_number($x) returns a false value, but it's only the second one liner that warns when $x is used in numeric context. Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|