[Israel.pm] How to remove elements according to a filter from an array

Gabor Szabo szabgab at gmail.com
Fri May 25 08:03:58 EEST 2007


I am sorry to be such an @$@%@ but have you actually measured that
you have a problem with speed at the point of deleting the elements?
How big is that array anyway?

Maybe the whole operation takes 0.01% of the total run time?

On the other hand if the array is really so big, maybe you reached the limit
of your memory when you have it twice in there (when using grep)?
Then maybe you don't have to hold all this information in memory all the time?

Now that you have the suggestions from others I would be really glad to see
some benchmarks you publish on the relative speed of
grep vs loop and splice.

Gabor

On 5/24/07, Yossi Itzkovich <Yossi.Itzkovich at ecitele.com> wrote:
> Hi,
>
> Assuming I have a big array, and I want to remove elemnts according to a
> criteria, how do I do it ?
> Please note, I am not asking about getting a new list of elements that
> passed the filter (like grep does), but removing the items from the
> original list.  For a big array (and assuming that arrays are
> implemented with linked list (is it ?)), then removing items from the
> original list might be much faster.
>
>
> Yossi

-- 
Gabor Szabo
http://www.szabgab.com/
Perl Training in Israel  http://www.pti.co.il/



More information about the Perl mailing list