in reply to question about: my $a AND sort {$a <=> $b} keys %hash
In short, never use $a and $b in your programs. It is explicitly mentioned in perlvarCan't use "my $a" in sort comparison at pmonks06082015.pl line 4.
$a $b Special package variables when using sort(), see sort. Because of this + specialness $a and $b don't need to be declared (using use vars , or + our()) even when using the strict 'vars' pragma. Don't lexicalize th +em with my $a or my $b if you want to be able to use them in the sort +() comparison block or function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: question about: my $a AND sort {$a <=> $b} keys %hash
by Laurent_R (Canon) on Aug 06, 2015 at 09:29 UTC |