in reply to Manipulating Array Indexes

If you want array elements, why do you use pop ? This modifies the array in question...

Maybe you can show us your code that "almost" works and tell us how it fails for you.

The simplest approach to get the next three items after a given index I can think of is:

use feature 'signatures'; sub next_three_items( $array_ref, $index ) { return $array_ref->[$index+1], $array_ref->[$index+2], $array_ref->[$index+3], ; }

... but maybe I have not understood your requirements well...

Replies are listed 'Best First'.
Re^2: Manipulating Array Indexes
by perlfan (Parson) on Sep 07, 2020 at 16:36 UTC
    I noticed the use of pop, also. It's also taking elements from the RHS of the list which may not be intuitive in this application. The index of elements to the left of the tail of the array would not be affected, but the overall size of the array certainly is so any number derived from it will certainly change.