Perl will use scalar context when it expects a scalar. @ary in scalar context is the number of elements so $#ary and @ary-1 are the same. This is perhaps a little more elegant.
for my $i (0..@{$object_ref->{array_ref}}-1) { # $i got the index }
In reply to Re: A question of perlish elegance on array loop
by tachyon-II
in thread A question of perlish elegance on array loop
by ait
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |