Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Validation of UserInput is a positive Integer or not?by ExReg (Priest) |
on Dec 07, 2015 at 20:05 UTC ( [id://1149606]=note: print w/replies, xml ) | Need Help?? |
I think what you meant to write was if ($days =~ /^\s*[1-9][0-9]*\s*$/)The way you wrote it, it would only match a value of $days equal to "1-90-9" plus or minus leading/trailing spaces and the last nine. Much better is the approach taken by toolic, ww, and Apero.
In Section
Seekers of Perl Wisdom
|
|