go ahead... be a heretic | |
PerlMonks |
Re: How do I completely remove an element from an array?by jaa (Friar) |
on Mar 21, 2003 at 11:07 UTC ( [id://244828]=note: print w/replies, xml ) | Need Help?? |
Be careful using splice during array iteration. Note the subtle bug here:
Values 2 and 4 are never actually tested for; iteration skips them completely! If you want to iterate over an array removing some items, try something like:
And, this being Perl I bet there are many other safe iteration/splice approaches... 8-)
In Section
Seekers of Perl Wisdom
|
|