I
it_says_BALLS_on_your forehead
Is there cleaner way of writing this:
foreach $send (0...$#sr) {
foreach $recv (0...$#{$sr[$send]}) {
foreach $round (0...$#{$sr[$send][$recv]}) { print
"$sr[$send][$recv][$round]:\n";
}
}
}
yes. you needn't use an integer iterator. it's actually more efficient
(and cleaner) to iterate over the array elements themselves.
for my $lev1 ( @sr ) {
for my $lev2 ( @{$lev1} ) {
for my $lev3 ( @{$lev2} ) {
print "$lev3\n";
}
}
}
....you can also probably use maps or something more esoteric if you're
more concerned with brevity and less concerned with readability. also,
i'm not sure if it's more efficient to dereference the arrayref
outside the nested loops or not. if i weren't so lazy i'd benchmark...