in reply to Deleting specific element in array in FOREACH loop
You need to count backwards here so that you don't miss any entries when they shift around.for (my $i = $#array; $i > -1; $i--) { # Delete element here if it matches. splice @array, $i, 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Deleting specific element in array in FOREACH loop
by GrandFather (Saint) on Sep 15, 2006 at 20:01 UTC | |
by ikegami (Patriarch) on Sep 15, 2006 at 20:08 UTC | |
by mreece (Friar) on Sep 15, 2006 at 20:15 UTC | |
by ikegami (Patriarch) on Sep 15, 2006 at 21:47 UTC |