the_slycer,
In addition to the proper de-referencing that liz illustrates, you are using $a as an unscoped global. You should avoid using $a and $b as variable names as they are used by Perl for sorting. See perldoc -f sort. It should then be properly scoped with my or *gasp* our if you really need it to be global.