http://www.perlmonks.org?node_id=552306


in reply to finding the distinct elements in an array

For example using that code:

my %seen; my @distinct_elems = grep { !$seen{$_}++ } @array;

or maybe

my %seen = map { $_ => 1 } @array; my @distinct_elems = keys %seen;

The first example even gives you the number of occurence of each element.

Cheers, Flo