in reply to Re: question about: my $a AND sort {$a <=> $b} keys %hash
in thread question about: my $a AND sort {$a <=> $b} keys %hash
That's why you should never use $a and $b as variable names.
Personally, I think instead of promoting a blanket ban on using lexical $a & $b -- which 9x% of code can use safely and usefully -- it would be better to change the documentation to show the use of:
my @sorted = sort{ $::a <=> $::b } @array;
which avoids the problem and clearly marks out the special usage of these variables for sort.
A simple change that would easily fix the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: question about: my $a AND sort {$a <=> $b} keys %hash ($::a & $::b)
by choroba (Cardinal) on Aug 06, 2015 at 21:44 UTC | |
by BrowserUk (Patriarch) on Aug 06, 2015 at 22:03 UTC |