in reply to Re: How to check if a scalar value is numeric or string?
in thread How to check if a scalar value is numeric or string?
And you might think the following code won't give you a divide by zero error:say "12" | "34"; # 36 say 12 | 34; # 46
but it will if $num eq '00'.if ($num && $num =~ /^[0-9]+$/) {say 1/$num}
Devel::Peek is a tool that can tell you whether scalar holds a numeric value or not (look for the IV and NV flags).
|
|---|