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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Logic for elimination of duplicate values from an array in perl for windows platform

Replies are listed 'Best First'.
Re: Logic for elimination of duplicate values from an array in perl for windows platform
by Joost (Canon) on Mar 11, 2005 at 11:34 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Logic for elimination of duplicate values from an array in perl for windows platform
by sh1tn (Priest) on Mar 11, 2005 at 11:49 UTC
    # The same (obviously working): @a = qw(1 2 3 4 5 4 3 2 1); @b = grep { !$_{$_}++ } @a; print "@b" #1 2 3 4 5


    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Logic for elimination of duplicate values from an array in perl for windows platform
by Ninthwave (Chaplain) on Mar 11, 2005 at 11:44 UTC
    I would place the array values into a hash as key values. This would eliminate duplicates.
    my %hash; my @array; foreach my $Item (@array){ $hash{$Item} ++; } foreach my $key (keys %hash) { # key is the values that would be in your new array }

    "No matter where you go, there you are." BB