Hiya! I have a syntax error. But i don't know whats causing it. Can anyone help? Heres the offending code.
#!/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"; } }
And here are the errors i get.
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.

In reply to Simple problem, cant fix? by The Elite Noob

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.