in reply to Re: How do I completely remove an element from an array?
in thread How do I completely remove an element from an array?
You can also avoid the 'sliding' problem of skipping over elements because you removed the element before them by iterating backwards:
for(reverse (0 .. $#items)) { splice(@items, $_, 1) if ($items[$_] == 1 || $items[$_] == 3); }
Which is slightly obfuscated, but works because the sliding end of the array contains only the elements you have already checked...
| We're not surrounded, we're in a target-rich environment! |
|---|
|
|---|