for my $i (0..4) { for my $j (0..4) { $array[$i][$j] = something($i,$j); } }