in reply to looping through array references
I echo GrandFather's reply.
I'd also like to emphasize that Super Search is your friend. Searching for 'loop array index' finds a couple of recent threads that are quite relevant:
use warnings; use strict; use List::MoreUtils qw( each_array ); my @array = ( 'a' .. 'g' ); my $a_obj = each_array( @array ); while( my $var = $a_obj->() ) { my $i = $a_obj->( 'index' ); print "got $var at $i\n"; }
got a at 0 got b at 1 got c at 2 got d at 3 got e at 4 got f at 5 got g at 6
|
|---|