in reply to Suppressing Warning/Error messages
The best thing would be to simply check that $SRVCH conforms to what you expect, that is, a sequence of only digits, before doing the numerical checks:
if( ($SRVCH =~ /\D/) # a non-digit || ($SRVCH > 22) # or greater 22 ||($SRVCH < 1) # or smaller than 1 ||($SRVCH =~ /(\s+)/) # or empty string (but see above) ||($SRVCH =~ /[a-zA-Z]/) # or a to z ){ ...
Also, there is no need to shell out to sleep, because Perl has sleep as a built-in function. See also Time::HiRes if you need sub-second sleep.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Suppressing Warning/Error messages
by intoperl (Acolyte) on Aug 27, 2015 at 10:29 UTC | |
by Corion (Patriarch) on Aug 27, 2015 at 10:32 UTC | |
by intoperl (Acolyte) on Aug 27, 2015 at 10:41 UTC |