in reply to Using $a and $b for sort

Sorting a hash table? Do you mean sorting keys in a hash? Or?

If you have lexicalized $a and $b (with my), you won't be able to use them in sort in the same or in the child block:

km@krot:/home/km> perl -le 'my $a = "q"; my $b = "x"; print join "-", +sort { $a cmp $b } qw(foo bar baz); print $a; print $b;' Can't use "my $a" in sort comparison at -e line 1.

If you have lexicalized $a and $b in a separate block, you can use $a and $b in sort (note that both $a and $b are empty in last prints):

km@krot:/home/km> perl -le '{my $a = "q"; my $b = "x";} print join "-" +, sort { $a cmp $b } qw(foo bar baz); print $a; print $b;' bar-baz-foo

Please read perldoc -f sort and perlvar. I'd avoid use of $a and $b altogether.