in reply to similar items in a list
In general, use a hash, with your values as the keys, to find unique items.
@array = qw(1 2 3 4 5 5); $hash = { map { $_ => 1 } @array }; my @sorted_unique_values = sort keys %$hash;
Perlfaq lists a more efficient way of doing this for a pre-sorted array
updated: added a link to FAQ, since it's FA.
|
|---|