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

Well, that's still two passes, but it's one line, which gets a ++BrowserUk from me! :-)

-- Mike

--
just,my${.02}

  • Comment on Re: Re: removing duplicated elements from array, with a difference

Replies are listed 'Best First'.
Re: Re: Re: removing duplicated elements from array, with a difference
by Anonymous Monk on Aug 28, 2002 at 18:41 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

      This should do it if your pattern is can be reliably matched by a single regex

      my $pattern = qr/a regex that matches your pattern/; my @deduped = grep { !exists $count{$_} or $count{$_} == 1 } map { /$pattern/ and $count{$_} ++; $_ } @data;

      What's this about a "crooked mitre"? I'm good at woodwork!