Next | Program Repair Shop | 163 |
Don't represent an empty box was "?" just because you want it to print that way
One reason why not: It makes it hard to change the output!
For example, to change "?" to " "
In the original version of the program, much unrelated code must change:
63 $squares = [ 64 ['?', '?', '?'], ...
214 foreach $x(0..2) { 215 if ($squares->[0][$x] eq "?") { ...
In the modified version, only this one line needs to change:
for my $row (0..2) { for my $col (0..2) { print ("<td align=center>" . ($squares->[$row][$col] || " ") . "</td>\n"); } print ("</tr><tr valign=middle>\n") unless $row == 2; }
Next | Copyright © 2002 M. J. Dominus |