in reply to TicTacToe Code Help.

You use a for loop for the moves, which will always execute the contents of the loop 9 times. Most of the time, you don't need that many. There is a way to break out of the loop, but the more conventional method is to have something like:

my $win = 0; my $i = 0; do { $i += 1; printf "Player %d's turn:\n",2-$i%2; # game code here # when a winning move is detected: $win = 1; } until (($win) || ($i == 9)); printf "%s won\n", $win ? sprintf "Player %d",2-$i%2 : "Nobody";