in reply to Validating numeric input

It's a little more complicated than that to validate numbers. That regex doesn't allow negative numbers, nor does it allow decimal values. It only accepts positive integers.

For authenticating a single number, it's pretty easy to use Scalar::Util's looks_like_number() function.

You could split on whitespace to isolate two entities, and then test each one to see that it looks like a number.


Dave

Replies are listed 'Best First'.
Re^2: Validating numeric input
by Anonymous Monk on Feb 05, 2005 at 06:12 UTC
    I noticed. I am able to select for positive integers, but thats about it! When I try to do something like its just no go! This is probably fraught with mistakes, going from memory, but I'm sure you get the point Bang line $value1=shift $value2=shift unless (($value1 >= 0) or ($value1 <= 0) or ($value2 >= 0) or ($value2 <= 0)){ die; $sum "blah blah"; print "blah blah sum";