On May 18, 2004, at 9:14 PM, Jason Dusek wrote:
Hi,
Is there an easy way to get all the unique elements of an array? i.e. is there some module or function that does that sort of thing?
There are excellent modules to handle this, but it's also pretty simple to roll your own in most cases:
sub unique { # see title of this message for usage my @all = @_; my %seen; $seen{$_}++ foreach @all; return keys %seen; }
Hope that helps.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>