in reply to $#{$array_ref} changes in loop

Don't do it that way! The code is clearer and more maintainable (and actually works) if you:

for my $i ($i .. $#{$eventscores} ) {

or:

for my $eventscore (@$eventscores} ) { $rider_id = $eventscore->[0]; while ( $eventscore->[0] == $rider_id ){ push (@scores, $eventscore->[2] ); $i++; } #...more code.. unrelated to loop }

as appropriate.

Update: Completely bogus code - doesn't do what the OP's code intended!


DWIM is Perl's answer to Gödel