http://www.perlmonks.org?node_id=221086


in reply to Re: count sort & output
in thread count sort & output

A less verbose way to do something similar:

my $data = do { local $/; <DATA> }; my $patt = join '|' => map quotemeta, 'a' .. 'z'; my %freq; $freq{$1}++ while $data =~ /($patt)/go; # etc...

Of course, counting occurrences of mere letters should normally be done using tr. ;-)

Also, mkent may want to save intermediate (sorted) results to avoid duplicating work.