Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my $program_guess = int(rand 10)+1; while (1) { print "Please give a number between 1 and 10\n"; my $user_guess = <STDIN>; chomp $user_guess; if ($user_guess > $program_guess) { print "The number you guessed is higher, please try again!\n"; next; } elsif ($user_guess < $program_guess) { print "The number you guessed is lower, please try again!\n"; next; } print "You got the correct number!\n"; last; }
|
|---|