rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Using regex, I have taken a value and now I want to report a error message if it is not a numeric value. My lines are below:
if($_ =~ /<blk id="(.+?)"\/>/g) { my $blk=$1; if($blk != \d){print "Invalid value"} }
Now, whether the value is 1 or abc, I am not getting the error. It should accept 1 but not abc. Could anyone help me to identify what's wrong in the code?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking whether a value is numeric or not
by almut (Canon) on Nov 27, 2008 at 08:20 UTC | |
|
Re: Checking whether a value is numeric or not
by Krambambuli (Curate) on Nov 27, 2008 at 08:08 UTC | |
by gwadej (Chaplain) on Nov 28, 2008 at 14:36 UTC | |
|
Re: Checking whether a value is numeric or not
by hda (Chaplain) on Nov 27, 2008 at 10:18 UTC | |
|
Re: Checking whether a value is numeric or not
by Gangabass (Vicar) on Nov 27, 2008 at 08:25 UTC |