in reply to Simple Anon Hash Query

In addition to what davido said, don't use curlies to initialize a hash. Your first line ( %a = {};) should be:
%hash = ();
(%a doesn't really conflict with the $a that is used by the sort function, but why create a chance for confusion?)

Curlies are used like that when initializing a reference to a hash:

my $hashref = {}; $$hashref{level1_key}{level2_key}{level3_key} = "value"; ... for my $key1 ( keys %$hashref ) { for my $key2 ( keys %{$$hasref{$key1}} ) { for my $key3 ( keys %{$$hasref{$key1}{$key2}} ) { # do something with $$hashref{$key1}{$key2}{$key3} } } }