while (1) { ########### # Heart of the game- Choose and scramble a word ########### my $word = $words[rand @words]; my @scramble = split(//, $word); @scramble = sort { (-1,1)[rand 2] } @scramble; print "\n\nGuess the scrambled word: "; foreach (@scramble) {print $_}; print "\n\n"; my $attempts = 0; while ($attempts++ < $max_attempts) { ##### # Take their guess ##### my $guess = ; chomp($guess); if ($guess ne "$word") { print "$guess is incorrect.\n"; $attempts++; } else { print "Congratulations! The scrambled word was $word.\n\n"; } } }