if ($dist[$b] >= 0) { while ($dist[$b] >= 0) { ... } #### for my $i (0 .. $#blocks) { #### for (@blocks) {