in reply to remove duplicates
This question pops up once and a while. It is mostly
referred to as:"how to find unique elements in an array",
as you can easily split you string on " "'s.
I was wondering, why isn't there a unique method in perl?
This seems quite usefull.
Anyway, I defined mostly a UNIVERSAL method like this
and just call it like :sub unique { my $self=shift; my %tmp; map { %tmp{$_}=1 } @_; return keys %tmp; }
But, anyway, since blakem and joe++ gave perfectly good answers, I rest my case :-)$o->unique(@array); # with $o my blessed object
|
|---|