The Elite Noob has asked for the wisdom of the Perl Monks concerning the following question:
And here are the errors i get.#!/usr/bin/perl -w # ticTacToe.pl use warnings; use strict; my @pieces = (" ") x 9; # value of square. NULL if empty x for x and o + for o. my $input; my $outcome; # 1 for win, 2 for loss. 3 for Tie. my $playerPiece; my $aiPiece; my @markers = ("o", "x"); my $totalMarkers = @markers; sub updateScreen{ # To update screen after each move. print " $pieces[6] | $pieces[7] | $pieces[8]\n"; print "-----------\n"; print " $pieces[3] | $pieces[4] | $pieces[5]\n"; print "-----------\n"; print " $pieces[0] | $pieces[1] | $pieces[2]\n"; } sub helpGame{ } system("reset"); # reset screen. print "Welcome to my Tic Tac Toe Game!\n"; print "I hope you like it and have fun\n"; print "BTW, you can't choose who you are...\n"; print "Type quit to quit program. Help for help.\n"; $playerPiece = $markers[rand $totalMarkers]# randomly choose x or o fo +r player. if($playerPiece eq "x"){ $aiPiece = "o"; } else { $aiPiece = "x"; }; print "The player is = $playerPiece\n"; print "the Ai is = $aiPiece\n"; while($outcome == 0){ # main processing loop print "\n"; &updateScreen; print "\n"; $input = <STDIN>; if($input =~ /[^1-9]/){ # Used to check for input words. if($input eq("quit" || "exit")){ # Checks what word is. print "\n"; print "Bye! Hope you liked it!\n"; print "\n"; exit; } else if($input eq "help") { &helpGame; redo; } else { print "\n"; print "That is invalid input...\n"; redo; } } if($input =~ /[1-9]/){ print "\n"; } }
syntax error at ticTacToe.pl line 33, near "){"
syntax error at ticTacToe.pl line 53, near "else if"
syntax error at ticTacToe.pl line 65, near "}"
Execution of ticTacToe.pl aborted due to compilation errors.
Thanks for help! Its a tic tac toe system btw.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple problem, cant fix?
by Corion (Patriarch) on Feb 27, 2011 at 19:56 UTC | |
|
Re: Simple problem, cant fix?
by Ratazong (Monsignor) on Feb 27, 2011 at 19:49 UTC | |
|
Re: Simple problem, cant fix?
by toolic (Bishop) on Feb 27, 2011 at 19:52 UTC | |
|
Re: Simple problem, cant fix?
by cdarke (Prior) on Feb 27, 2011 at 21:56 UTC | |
|
Re: Simple problem, cant fix?
by AnomalousMonk (Archbishop) on Feb 27, 2011 at 21:04 UTC |