Next | Program Repair Shop | 144 |
75 $rounds = { 76 round1 => { 77 player => $page->param('round1_x'), 78 computer => $page->param('round1_o') 79 }, 80 round2 => { 81 player => $page->param('round2_x'), 82 computer => $page->param('round2_o') 83 }, ...
Do Not Repeat Code
Eliminating the repetition turns 16 lines into 4
for my $rn (1..5) { $rounds->{"round$rn"} = { player => $page->param("round${rn}_x"), computer => $page->param("round${rn}_o"), } }
The structure is just as easy to see
Maybe easier because you can be instantly sure that the analogy is true
Next | Copyright © 2002 M. J. Dominus |