in reply to regex for numbers

Hello BernieC,

you got obvious and wise answers; I'm not here for this :) What about { local $@; eval 0 + $maybe_a_number ... }?

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: regex for numbers
by choroba (Cardinal) on Apr 07, 2021 at 18:59 UTC
    Perl happily accepts 0 + '1.1.' (well, it warns, but it doesn't throw an exception). So, eval alone isn't enough.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]