in reply to Check for Positive Integer entry only
You might want to look at Regexp::Common::number in general, but I don't see anything ready-made to do what you want. Here's a pattern I might use:
$dataEntry =~ m{ \A # beginning of string \+? # optional plus sign \d+ # one or more digits \z # end of string }xms
Using Regexp::Common, that might be:
use Regexp::Common qw( number ); $dataEntry =~ /$RE{num}{int}/ && $dataEntry == abs $dataEntry
If you want to allow for white space in your data entry, you could add \s* into your patterns.
Update: After consideration of the contributions of the other monks, I think this is a better expression than the one I have above:
m{ \A # beginning of string \+? # optional plus sign [0-9]* # optional digits, including zero [1-9] # mandatory non-zero digit [0-9]* # optional digits, including zero \z # end of string }xms
This incorporates Nkuvu's observation that a value of zero should not be allowed and mreece's suggestion that \d is not always the best way to match digits (though I find this counterintuitive). It also passes my own test suite.
In Section
Seekers of Perl Wisdom