in reply to Hash code bug

It's worth pointing out a couple of things here...
  1. Avoid using the scalar variables $a and $b. These are special global variables that are used by sort
  2. If you are new to Perl, you should always, always use strict and use warnings in every perl script that you write (at least until you know Perl well enough to be able to explain when it is safe or reasonable to not use them). This will save you many many hours of pulling your hair out because of silly typos and coding mistakes.

Regards,
Darren :)