in reply to Re: Removing array elements
in thread Removing array elements

While splice is the way to remove elements from an array, nb perlsyn:

If any part of LIST is an array, "foreach" will get very confused if you add or remove elements within the loop body, for example with "splice". So don't do that.

In this situation I usually (as others have suggested) use a C-style for loop.

Replies are listed 'Best First'.
Re^3: Removing array elements
by Zaxo (Archbishop) on Aug 25, 2005 at 04:47 UTC

    Hence reverse. If you remove or insert elements from the end, the positions of unvisited elements are not affected.

    After Compline,
    Zaxo