# ... print "\nGuess (Q to quit): "; chomp($inp = <>); last if $inp =~ /^[qQ]/; # ...