for(@in){ $hash{$_}++; } foreach my $key (keys %hash){ print "$key is lonely\n" if ($hash{$key} == 1); print "$key has friends\n" if ($hash{$key} != 1); }
thor
Update: changed %hash{$_}++ to $hash{$_}++ to make it correct.
In reply to Re: Get All Duplicated Elements in an Array (Once, without shifting)
by thor
in thread Get All Duplicated Elements in an Array (Once, without shifting)
by George_Sherston
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |