my %counts; ++$counts{$_} for @array; print("There are $counts{$_} element(s) of $_\n") for sort keys %counts;