My constraint: Don't use a hash!
my @array = qw/A B C B D B D/; my $c=1; foreach my $k (sort @array) { next if --$c; $c= scalar grep { $_ eq $k } @array; print "There are $c element(s) of $k\n"; }
Update: Fixed thanks to gashos coment.
In reply to Re: How to find number of unique elemenst in array
by Skeeve
in thread How to find number of unique elemenst in array
by gasho
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |