in reply to Braces around a section of code
I agree with my fellow monks who have already replied and might simply add a reference to Coping with Scoping for good measure.
For other clues as to why the author has used a block here, look at the immediately preceeding and following lines (which you have not yet shown us).
Finally, this line:
for ($i=0; $i<$armload_cnt; $i++){
suggests that the author is either not the most familiar with Perl or perhaps has translated this code from another language and the outer braces might simply be a residual figment of that. The more Perlish way to write this loop would be
for my $i (0 .. $armload_cnt - 1) {
Edit: fixed off-by-one in perlish loop (thanks AnomalousMonk for spotting). This is another reason IMHO why Perlish loops are superior - there's no need to inspect the operators inside the brackets so closely.
|
|---|