sub count { my $str = shift; my %h; $h{$_}++ for split //, $str; return \%h; }