in reply to Validating numeric input

When I am expecting an integer I often just cast it with the perlfunc:int keyword like this:
my $line = <>; chomp $line; my $num = int $line;
Now of course that maps input like "asdf" to the integer zero so you still need to check the input like you are doing. There are some related comments in the perlfaq at How do I determine whether a scalar is a number/whole/integer/float?