while (1) { chomp( my $answer = ); if ($answer eq $x) { print "Great, $answer is correct.\n"; print "Hit enter to continue, Ctrl+C to exit."; ; last } else { print "Sorry, $x is not correct, please try again.\n"; } }