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++; } }
In reply to Re: Efficient array element deletion
by fert
in thread Efficient array element deletion
by kennethk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |