http://www.perlmonks.org?node_id=728214


in reply to Efficient array element deletion

If I have a long array and my goal is to perform some test on each element and remove those elements that fail, what are the best ways to do it from CPU and memory standpoints?

I think preventing those entries from ever making it to the array is far more efficient then pushing them on and then later ''grep-ing'' them out.

Any form of array shrinkage is costly (as has been proved throughout this whole thread).