7 use Moose::Autobox::Undef;
14 print("\n") unless ((++$count) % 3);
18 my $board = [ ('.') x 9 ];
22 my $choice = [ 1 .. 9 ]->any;
25 while ($board->any eq '.') {
28 print("Player ($player), enter the Position [1-9]: ");
31 unless ($in == $choice) {
32 print "\n\tPlease enter a value within 1-9\n\n";
37 if ($board->[$idx] ne '.') {
38 print "\n\tElement already entered at $in\n";
42 $board->[$idx] = $player;
48 [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ],
49 [ 0, 3, 6 ], [ 1, 4, 7 ], [ 2, 5, 8 ],
50 [ 0, 4, 8 ], [ 2, 4, 6 ],
53 my $row = $board->slice($_);
55 if (($row->all eq 'X') || ($row->all eq 'O')) {
56 print("\n\tPlayer ($player) Wins\n");
62 $player = $player eq 'X' ? 'O' : 'X';
70 tic_tac_toe.pl - Tic-Tac-Toe
74 This is a Moose::Autobox port of a perl6 implementation
75 of the classic Tic-Tac-Toe game.
77 This uses a modified version of the one Rob Kinyon created
78 L<http://www.perlmonks.org/index.pl?node_id=451302>.
82 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
84 =head1 ACKNOLEDGEMENTS
86 This code was ported from the version in the Pugs examples/
87 directory. The authors of that were:
89 mkirank L<http://www.perlmonks.org/index.pl?node_id=451261>
91 Rob Kinyon L<http://www.perlmonks.org/index.pl?node_id=451302>
93 Stevan Little, E<lt>stevan@iinteractive.comE<gt>