in reply to Error Sorting Array Reference?

Because $a and $b are special variables that are used by sort. You shouldn't really use them in your Perl code. See perldoc sort.

When reporting errors, it's usually a good idea to include the text of your error message. Also, try adding "use diagnostics" to your code to get a better description of the error.

Can't use "my $a" in sort comparison at ./sort line 7 (#1)
(F) The global variables $a and $b are reserved for sort comparisons. You mentioned $a or $b in the same line as the <=> or cmp operator, and the variable had earlier been declared as a lexical variable. Either qualify the sort variable with the package name, or rename the lexical variable.
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg