in reply to question re: hash sorting

Assuming that this is called like:
@sorted=sort{$tallies{my $a} <=> $tallies{my $b}} keys %tallies
, here's how it works.

keys %tallies returns a list of all of the keys in %tallies. sort sorts the provided list using the provided sort routine

The provided sort routine is given two items from the provided list (in this case the keys for %tallies), in $a and $b, and returns 1 if $a is greater, -1 if $b is greater, or 0 if they are equal. This particular sort routine takes the $a and $b from the list, looks them up in the %tallies hash, then compares the numeric values of the results using the spaceship operator (<=>).

By calling the sort routine repeatedly, Perl sorts the list, and sort returns the sorted list.

You can learn more about this by reading about sort and keys in perlfunc(1), and about <=> in perlop(1).