in reply to Minor querry!!

I think you want something like this:
use strict; use warnings; my($a) = <STDIN>; chomp($a); if ($a !~ /^\d+$/) { print "Sorry - you didn't give me a number.\n"; exit 1; } else { print "Yay! That's a number!\n"; }
Hope that helps,
Shendal

Replies are listed 'Best First'.
RE: Re: Minor querry!!
by mrmick (Curate) on Jun 27, 2000 at 21:06 UTC
    Another variation on Shendal's solution could be to allow for decimals. I hardly ever work with whole numbers (not through choice, but because of the data we are responsible for here).
    my $number = <STDIN>; chomp $number; if ($number !~ /^\d+\.?\d*$/) { print "$number is not a number.\n"; exit 1; } else { print "$number is a number!\n"; }
    I hope this proves useful to someone. mrmick