in reply to Convert loop and if constructs from C to Perl
is the same as:for (i = 0; i < 10; ++i) printf("%d\n", i);
and similarly for other constructs.for (i = 0; i < 10; ++i) { printf("%d\n", i); }
Personally, I always uses the braces in these contexts in C (as you must in perl), since I think it makes things clearer and it is more robust to future maintenance, where the potential problem is that someone may try to add a second statement to the loop but forget the braces, in which case what they have done is add a statement after the loop.
Update: to be more correct, some statements aren't terminated by a semi-colon and sorry if that is confusing. Basically, the indentation in the code above is accurate as far as the scope of the if's and for's goes.
|
|---|