in reply to Re^2: Valid Numbers or decimals
in thread Valid Numbers or decimals

neither of these cope with the fact that...
my $num = 1_000_000;
...is a perfectly valid number declararion. I think what the OP is after is way to get at what Perl is doing when it compains after you do something like this...
my $num = 1_000_000; if ($num == "ssf") { print "uh oh"; }
Re-writing an existing Perl check in a regex is best avoided if possible IMHO
---
my name's not Keith, and I'm not reasonable.

Replies are listed 'Best First'.
Re^4: Valid Numbers or decimals
by zentara (Cardinal) on May 06, 2005 at 16:20 UTC
    How about:
    #!/usr/bin/perl my @numbers = (0, 3.14, 5 , 4_000_000, 3_000.42, "any strings 234 "); print "@numbers\n"; my @numgoods = grep{/^(\d*[\._]?\d+)$/ } @numbers; print "@numgoods\n";

    I'm not really a human, but I play one on earth. flash japh