in reply to How can I count and display unique items in an array? (was: array counting)

You build a hash with the elements as keys and an array reference as value. The referenced array contains the indices of the element indexed by the key, and the number of elements of that array is logically the number of occurences of the element in the original array.
my (@array, %hash); push @{$hash{$array[$_]}}, $_ for 0..$#array; for(keys %hash) { print "Element: $_\nOccurences: ", scalar @{$hash{$_}}, "\n"; print("At indices: ", join(",", @{$hash{$_}}), "\n"); }
____________
Makeshifts last the longest.