(as a variation of Haukex' answer, which is more straight forward )
>perl my $answer = 42; { print "What is the answer? "; chomp( my $input = <STDIN> ); if ( $input == $answer ) { print "Good!\n"; } else { print "Please try again.\n"; redo; } } __END__ What is the answer? 1 Please try again. What is the answer? 2 Please try again. What is the answer? 42 Good!
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re: Repeat question (redo)
by LanX
in thread Repeat question
by hchana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |