# $eventscores is an arrayref to an array of arrayrefs. # everything works fine until the last while iteration while ( $i <= $#{$eventscores} ) { $rider_id = $eventscores->[$i]->[0]; while ( $eventscores->[$i]->[0] == $rider_id ){ push (@scores, $eventscores->[$i]->[2] ); $i++; } #...more code.. unrelated to loop } #### $array_count = $#{$eventscores} #### while ($i <= $array_count)