mkurtis has asked for the wisdom of the Perl Monks concerning the following question:

I did a supersearch, and found How can I display a unique array if it contains some repeated elements, but this doesn't work. I still get all kinds of duplicates. I have tried all kinds of hash keys and other things as well.
foreach $term(@inputs) { @result = $words{$term}; push @results, @result; } undef @numbers{@results}; my @results2 = keys %numbers; print "@results2\n";
This still allows duplicates, and also combines some of the array elements, I'm assuming from push.

Thanks

Replies are listed 'Best First'.
Re: Removing duplicate elements from an array
by davido (Cardinal) on Apr 12, 2004 at 05:04 UTC
    my @nodupes = keys %{ map { $_ , undef } @inputs };

    Dave

Re: Removing duplicate elements from an array
by tachyon (Chancellor) on Apr 12, 2004 at 06:48 UTC
    my %unique; @unique{@dups} = (); my @uniq = keys %unique;

    If you want this data to be unique you might be better to use a hash in the first place.

    cheers

    tachyon

Re: Removing duplicate elements from an array
by biosysadmin (Deacon) on Apr 12, 2004 at 13:21 UTC
      Figured it out, @result contained blocks of numbers, so $result didn't pull out individual ones. Had to split them. Now it works fine.

      Thanks