Perl-Sensitive Sunglasses | |
PerlMonks |
Using number "0" as an input argumentby Doozer (Scribe) |
on Sep 22, 2015 at 08:39 UTC ( [id://1142708]=perlquestion: print w/replies, xml ) | Need Help?? |
Doozer has asked for the wisdom of the Perl Monks concerning the following question: Hi All. I'm after some help on dealing with a valid number "0" as an input argument. I have a script which takes input arguments. One of the arguments relates to a USB audio input device number on a Raspberry Pi. The device numbers start from 0 and increment depending on how many of these devices are installed. I know I can validate that the input argument was there via the following bit of code:
The problem I have is I also want to validate that the input is only a number. If I do regex pattern match validation against $in1 when it is "0", Perl gives me the uninitialized value error. I am aware that 0 translates to false. How can I use "0" as a valid number? I have tried looking on Google for an answer but have been unsuccessful.
Back to
Seekers of Perl Wisdom
|
|