in reply to Re: Array Cleaning
in thread Array Cleaning

Yes, I forgot to mention the duplicate entries. They should also be removed.

Another problem with grep is, that it is extremely slow with big arrays (at least I heard that :))

Replies are listed 'Best First'.
Re^3: Array Cleaning ("grep is slow")
by Aristotle (Chancellor) on May 03, 2003 at 03:01 UTC
    1. Never guess wildly at what may or may not be slow.
    2. Don't concern yourself with performance unless it is a problem.
    3. When you need performance, profile your code to find out where the problem is.
    4. If you really really need a very very fast program then why are you using Perl?
    And some quotes from the collection on my home node:
    More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity.
    — William A. Wulf, A Case Against the GOTO
    Rules of Optimization:
    Rule 1: Don't do it.
    Rule 2 (for experts only): Don't do it yet.
    — Michael A. Jackson

    Makeshifts last the longest.

Re: Re: Re: Array Cleaning
by crenz (Priest) on May 02, 2003 at 17:11 UTC

    Well, I find it hard to believe that a built-in perl function that has been optimised and is written in C should be slower than walking through the array yourself... (ie. doing the exact same thing the built-in is supposed to do). It is contrary to my own experience, at least. Plus I find myself too lazy to write and debug own code when I can use a built-in :).

    If you really have reason to believe what you've heard, why not just quickly whip up a benchmark.