in reply to removing duplicated elements from array, with a difference

I'm not sure of a good one-pass approach for this (but perhaps there is one). Here's a two-pass approach, one pass to create the "count" hash and another pass to remove duplicate elements.
$count{$_}++ for @array; @new_array = grep {$count{$_} < 2} @array;

-- Mike

--
just,my${.02}

Replies are listed 'Best First'.
Re: Re: removing duplicated elements from array, with a difference
by Anonymous Monk on Aug 28, 2002 at 18:28 UTC
    Thanks for your help, but I've realised that I need to do the same problem except that the duplicate may be a particular pattern within an element. So therefore all those elements containing that pattern need to be removed. thanks again, paul
      I've realised that I need to do the same problem except that the duplicate may be a particular pattern within an element. So therefore all those elements containing that pattern need to be removed.

      You may have to explain this further. To find the elements not matching a particular pattern you can use something like:

      @without = grep { !/PATTERN/ } @original;

      I'm not sure that addresses the issue you are trying to describe with the phrase "the duplicate may be a particular pattern within an element."

      -sauoq
      "My two cents aren't worth a dime.";