Jan 13, 2007 #1 kb0rhe Technical User Joined Dec 25, 2006 Messages 16 Location US I have a value and I want to know if it is a numeric value. There isn't anything to test a value if it is truly numeric. Nothing is jumping out at me. I have been looking online for a while. Douglas
I have a value and I want to know if it is a numeric value. There isn't anything to test a value if it is truly numeric. Nothing is jumping out at me. I have been looking online for a while. Douglas
Jan 13, 2007 1 #2 KevinADC Technical User Joined Jan 21, 2005 Messages 5,070 Location US numeric is harder to check than for simple digits: some ways that might work: Code: if (/\D/) { print "there is something that is not a digit"; } Code: if (/^\d+$/) { print "there are only digits in this thing so it's numeric."; } Code: if (/\d/ && /^-?\d*\.?\d*$/) { print "an integer, negative number, or a decimal but not some other type of numeric value"; } more ways to check here: http://perldoc.perl.org/perlfaq4.ht...her-a-scalar-is-a-number/whole/integer/float? - Kevin, perl coder unexceptional! Upvote 0 Downvote
numeric is harder to check than for simple digits: some ways that might work: Code: if (/\D/) { print "there is something that is not a digit"; } Code: if (/^\d+$/) { print "there are only digits in this thing so it's numeric."; } Code: if (/\d/ && /^-?\d*\.?\d*$/) { print "an integer, negative number, or a decimal but not some other type of numeric value"; } more ways to check here: http://perldoc.perl.org/perlfaq4.ht...her-a-scalar-is-a-number/whole/integer/float? - Kevin, perl coder unexceptional!