Another idea for improvement is to put the input in a loop and only exit the loop upon receiving the proper input. This is one way:
my $max; chomp($max = <STDIN>) while(not defined $max && $max =~ m/^[0-9]+$/); my $answer = int(rand($max))+1;
In reply to Re: Guess A Number
by MrYoya
in thread Guess A Number
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |