One pattern you can apply for that kind of thing is:
my $answer = 42; while (1) { print "What is the answer? "; chomp( my $input = <STDIN> ); if ( $input == $answer ) { print "Good!\n"; last; # break out of innermost loop } else { print "Please try again.\n"; } }
In reply to Re: Repeat question
by haukex
in thread Repeat question
by hchana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |