Next Program Repair Shop 159

Repeated Code

     for my $row (0..2) {
       print "<tr>";
       foreach my $col (0..2) {
         if ($squares->[$row][$col] eq "") {
           print ("<td><input type='checkbox' name='choice' value='[$row][$col]'></td>\n"); 
         }else {
           print ("<td>" . $squares->[$row][$col] . "</td>\n");
         } 
       }
       print "</tr>\n";
     }
     for my $row (0..2) {
       print "<tr>";
       foreach my $col (0..2) {
         print "<td>"
         print $squares->[$row][$col] 
            || "<input type='checkbox' name='choice' value='[$row][$col]'>"; 
         print "</td>"
       }
       print "</tr>\n";
     }


Next Copyright © 2002 M. J. Dominus