On May 19, 2004, at 10:14 AM, Jason Dusek wrote:
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?
It's a very common problem...
a simple solution is to use hash:
#!/usr/bin/perl
use strict;
use warnings;
my @array = qw(a s f d a s e c v b f f r e a a s d);
my %hash;
foreach my $el(@array) {
$hash{$el} ++;
}
foreach my $key (keys %hash) {
print $key."\t".$hash{$key}."\n" if $hash{$key} == 1;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>