- or download this
%seen = ();
@uniqu = grep { ! $seen{$_} ++ } @list;
- or download this
use strict;
use warnings;
...
my @shuffled = shuffle @unique;
print "shuffled: @shuffled\n";
- or download this
my @unique = unique(@array);
- or download this
sub unique {
my %seen;
my @unique = grep {!$seen{$_}++} @_;
return @unique;
}
- or download this
sub unique { local %_; grep !$_{$_}++, @_ }