http://qs321.pair.com?node_id=614505


in reply to Check for Positive Integer entry only

i'm not a big fan of \d, since it can lead to unexpected results: matching things that are "digits" but not useable as perl or database integers. when unicode enters the picture, there are 268 or so unicode characters that \d matches against.

what you probably want here is a string that starts with a number 1-9, followed by more numbers 0-9 (assuming that 03 is a bad entry), or just one or more numbers 0-9 (if 03 is a good entry).

if ($DataEntry =~ /^[1-9][0-9]*$/) { print "good entry\n"; } else { print "bad entry\n"; }
or
if ($DataEntry =~ /^[0-9]+$/) { print "good entry\n"; } else { print "bad entry\n"; }