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.

Krambambuli
---

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