In the first inelegant snippet, the index var continues to exist beyond the for loop. In the second elegant snippet, it does not. This is because in Perl 5, an implicit block is defined. Last I heard, this will not be the case in Perl 6 and these two snippets would be functionally equivalent. I would have written it this way in Perl 6:
for 0 .. $exprs.end -> $index { # ... }
Cheers - L~R
In reply to Re^2: How do you define "elegant"?
by Limbic~Region
in thread How do you define "elegant"?
by Mutant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |