Re: perlfaq4: How can I remove duplicate elements from a list or array?

[email protected] (Tony Cook) Fri, 1 Apr 2005 10:34:22 +1000
Newsgroups perl.perlfaq.workers,perl.documentation
Message-ID <[email protected]>
On Thu, Mar 31, 2005 at 03:09:00PM -0600, _brian_d_foy wrote:
> You can write this more briefly using a grep, which does the
> same thing.
> 
>    my %Seen = ();
>    my @unique = grep { ! $Seen{ $elem }++ } @array;

This should probably be:

    my %Seen = ();
    my @unique = grep { ! $Seen{ $_ }++ } @array;

Tony