Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Checking whether a value is numeric or not

by Krambambuli (Curate)
on Nov 27, 2008 at 08:08 UTC ( #726333=note: print w/replies, xml ) Need Help??

in reply to Checking whether a value is numeric or not

Well, what exactly do you define as being a "numeric value" ?

7.89e-200 ? 0xabc ? They both are numeric values...

If you think about a string of exclusive decimal digits, you might want to rewrite your test as
if($blk !~ /^[\d]+$/) {print "Invalid value"};
or so.


Replies are listed 'Best First'.
Re^2: Checking whether a value is numeric or not
by gwadej (Chaplain) on Nov 28, 2008 at 14:36 UTC

    For this particular case, I would probably use:

    if($blk =~ /\D/) { print "Invalid value";}

    For some reason, it seems clearer to me.

    G. Wade

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://726333]
[jedikaiti]: 'ello Monks

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2017-06-27 15:11 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (609 votes). Check out past polls.