Next | Program Repair Shop | 152 |
We had to make this change three times:
foreach $x(0..2) { if ($squares->[0][$x] eq "") { print_cell($squares, $page, $x, "0"); }else { print ("<td>" . $squares->[0][$x] . "</td>\n"); } }
Instead, use a loop:
for my $row (0..2) { for my $column (0..2) { if ($squares->[$row][$column] eq "") { print_cell($squares, $page, $column, $row); } else { print ("<td>" . $squares->[$row][$column] . "</td>\n"); } } print ("</tr><tr>\n") unless $row == 2; }
14 lines become 5
Next | Copyright © 2002 M. J. Dominus |