in reply to Efficient array element deletion
This will effectively 'shift' every thing over to the front of your array, avoiding double memory issues, and all you have to do is one final pass to "cleanup" the invalid entries at the end (pop @array until the length == $replace).my $replace = 0; for ( my $x = 0; $x< @array; $x++ ) { if ( # pass of your condition ) { $array[$replace] = $array[$x]; $replace++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficient array element deletion
by GrandFather (Saint) on Dec 04, 2008 at 23:36 UTC |