in reply to Re^2: the variable is lost
in thread the variable is lost

FWIW, using $a and $b outside of sort is always a mistake

Replies are listed 'Best First'.
Re^4: the variable is lost
by eyepopslikeamosquito (Archbishop) on Mar 09, 2012 at 09:36 UTC

    FWIW, using $a and $b outside of sort is always a mistake
    The special variables $a and $b are also used by List::Util's reduce function and by List::MoreUtils's pairwise function.

Re^4: the variable is lost
by JavaFan (Canon) on Mar 09, 2012 at 10:52 UTC
    For a grasshopper, just fresh out of the egg, and not really having a license yet to come anywhere near a keyboard, this is decent advice. It's the level of advice you give to a toddler who's about to start crawling. "Hot, don't touch".

    Anyone who has half a braincell he can fire up once a blue moon, however, will see how silly that is.

    A lot of code doesn't sort. Most code that does sort, doesn't even use the variant that makes Perl stuff $a and $b. And even if you do, even then you have to work hard to make a use of $a and $b make things mess up.

    If you really need to have a Pavlov reaction when you see an $a and/or a $b, and blind yourself from the fact a poster may have used well known example variable names, please keep your urges private, and don't hit that "create" button. It doesn't add any value.