in reply to Deleting elements from array questions

If you want to remove the elements from the array entirely, grep is the way:

@array = grep { $_ ne $item } @array;
That eliminates fencepost errors and leaves no empty slots in the array. Your code should work, but it does not remove the array slot.

Updade: Corrected pasteo.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Deleting elements from array questions
by sauoq (Abbot) on Aug 08, 2002 at 18:25 UTC
    If you want to remove the elements from the array entirely, grep is the way [Emphasis added]

    Well, grep is one way (and probably the one that will work best for the original question.) But splice is also a perfectly good way to remove elements from an array.

    -sauoq
    "My two cents aren't worth a dime.";