my @chessboard; my @back = qw(R N B Q K B N R); foreach (0..7) { $chessboard[0][$_] = "W" . $back[$_}; # White Back Row $chessboard[1][$_] = "WP"; # White Pawns $chessboard[6][$_] = "BP"; # Black Pawns $chessboard[7][$_] = "B" . $back[$_]; # Black Back Row } while (1) { # Print board foreach my $i (reverse (0..7)) { # Row foreach my $j (0..7) { # Column if (defined $chessboard[$i][$j]) { print $chessboard[$i]$j]; } elseif ( ($i % 2) == ($j %2) ) { print ".."; } else { print " "; } print " "; # End of cell } # end of foreach print "\n"; # End of row print "\nStarting square [x,y]: "; my $move = <>; last unless ($move =~ /^\s([1-8]),([1-8)/); my $startx = $1-1; my $starty = $2-1; unless (defined $chessboard[$starty][$startx]) { print "There's nothing on that square!\n"; next; } print "\nEnding square [x,y]: "; $move = <>; last unless ($move =~ /([1-8]},([1-8])/); my $endx = $1-1; my $endy = $2-1; # Put starting square on ending square $chessboard[$endy][$endx] = $chessboard[$starty][$startx]; # remove from old square undef $chessboard[$starty][$startx]; } "my" variable @chessboard masks earlier declaration in same scope at ./BP_Chap11_Exer1.pl line 29. "my" variable $i masks earlier declaration in same statement at ./BP_Chap11_Exer1.pl line 29. "my" variable $j masks earlier declaration in same statement at ./BP_Chap11_Exer1.pl line 29. "my" variable @chessboard masks earlier declaration in same statement at ./BP_Chap11_Exer1.pl line 30. "my" variable $i masks earlier declaration in same statement at ./BP_Chap11_Exer1.pl line 30. Scalar found where operator expected at ./BP_Chap11_Exer1.pl line 30, near "]$j" (Missing operator before $j?) elseif should be elsif at ./BP_Chap11_Exer1.pl line 31. syntax error at ./BP_Chap11_Exer1.pl line 19, near "$_}" syntax error at ./BP_Chap11_Exer1.pl line 23, near "}" Global symbol "$j" requires explicit package name at ./BP_Chap11_Exer1.pl line 30. Global symbol "$i" requires explicit package name at ./BP_Chap11_Exer1.pl line 31. Global symbol "$j" requires explicit package name at ./BP_Chap11_Exer1.pl line 31. Unmatched [ in regex; marked by <-- HERE in m/^\s([1-8]),([ <-- HERE 1-8)/ at ./BP_Chap11_Exer1.pl line 42.