![]() |
|
We don't bite newbies here... much | |
PerlMonks |
Re: Check for Positive Integer entry onlyby swampyankee (Parson) |
on May 09, 2007 at 18:08 UTC ( #614465=note: print w/replies, xml ) | Need Help?? |
I think that this exact case is handled in the Camel Book. The logic is quite straightforward:
Note that this does not check to see if the integer can be represented on your system. It also does not permit white space between the sign and the leading digit of the number being examined. Oops! This will pass 0, which is not a positive integer, although it is a valid integer. To correct the test replace this: with this
Doubtless, this is not the most efficient method. emc Insisting on perfect safety is for people who don't have the balls to live in the real world.
In Section
Seekers of Perl Wisdom
|
|