in reply to array manipulation

splice returns the array elements that were removed from the original array.   All offsets in Perl are zero based.

Replies are listed 'Best First'.
Re^2: array manipulation
by Anonymous Monk on Jun 15, 2009 at 16:56 UTC
    But that can change
    @a = 0..10; $[ = 2; warn $a[2]; warn splice(@a, 2, 1, 6); warn @a; __END__ 0 at - line 3. 0 at - line 4. 612345678910 at - line 5.
      Just a small note about your suggestion.

      I think changing $[ is very dangerous thing to do since the it is almost always 0. So if you need to change it for some reason make sure the change is local to the smallest scope needed.

      Thanks!

      I have spent too much time debugging my program on one occation when a module changed this globally ...

      si_lence