in reply to Is it safe to use join on a hash?
You may like:
use strict; use warnings; my @nums = (17, 10, 20, 33, 30, 40, 10, 33, 40, 15, 16, 17); my %values; ++$values{$_} for @nums; print join "\n", map{"$_: $values{$_}"} sort {$a <=> $b} keys %values;
which prints an ordered list of the unique values and their counts:
10: 2 15: 1 16: 1 17: 2 20: 1 30: 1 33: 2 40: 2
|
|---|