Next | Program Repair Shop | 145 |
for my $rn (1..5) { $rounds->{"round$rn"} = { player => $page->param("round${rn}_x"), computer => $page->param("round${rn}_o"), } }
My first cut at this looked different:
$rounds = { map {("round$_" => { player => $page->param("round${_}_x"), computer => $page->param("round${_}_o"), } )} (1..5) };
I tried it both ways
The for loop was much clearer
(map had too many parentheses)
Don't be afraid to Try it both ways
Next | Copyright © 2002 M. J. Dominus |