Help for this page

Select Code to Download


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