in reply to User input check 'Do until' loop

I realize you wanted to understand how to implement this yourself, and I'm glad others have already offered you good answers.

However a big part of programming in Perl is the virtue of Laziness...and knowing when (and how) to let others do the work for you.

The CPAN has a number of modules that can handle this kind of interactive prompt-read-validate process for you. For example, here is your entire input validation code rewritten using the IO::Prompter module:

use IO::Prompter; my $answer = prompt("Do you accept this challenge? ", -yesno) ? 1 : 2;

Whenever you're faced with what feels like a simple and commonly needed task, its always a good idea to see whether (a) Perl already has it built-in or (b) someone got fed-up and added it already.