in reply to Finding size of an array in an HoA
Other examples (of syntax) for using such braces for this:for ( 0..$#{$self->session->param('item')} ) { print $self->session->param('item')->[$_]."\n"; }
update: this one is also not optimal for the example because of its subroutine call being repeated a few times, (as shmem has meanwhile pointed out) but there are some more common situations where the for (;;) does optimise by avoiding a generated iteration array ... I often work with large A of Hs without subroutine calls and use this approach...# to iterate the elements directly for my $conf ( @{$self->session->param('item')} ) { print "$conf\n"; }
for ( my $i; $i <= $#{$self ->session->param('item') }; $i++ ) { print $self -> session -> param('item') -> [$i ] . "\n"; }
^M Free your mind!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding size of an array in an HoA
by shmem (Chancellor) on May 15, 2007 at 13:10 UTC | |
by Moron (Curate) on May 15, 2007 at 14:20 UTC |