$a and $b are default variables used for sorting in perl. That may not be the root of the problem, but then again... maybe it is. If you try the code using other two variables and it works, you know the problem is the default var thing. Google on perlvar. (I would love to link to perldoc.com or perlmonks, but perlmonks is out of date and perldoc is down > 90% of the time, grrr.)