in reply to Re: Modify hash reference itself
in thread Modify hash reference itself

$a is not necessarily a good choice for a lexical variable's name

Actually, to be completely pendantic, $a and $b are perfectly safe so long as you use an inline sort routine in the same scope. For example, this won't work:

xyz(1 .. 5); sub xyz { my $a = shift; sort { $a <=> $b } @_; print "$a\n"; }
But, the following will work:
xyz(1 .. 5); sub xyz { my $a = shift; abc(@_); print "$a\n"; } sub abc { sort { $a <=> $b } @_; }
Since abc() provides a different lexical scope than xyz(), everything is ok and $a within xyz() is safe.

But, your point of confusion is still good, as single-letter variables are poor.

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Re: Modify hash reference itself
by Anonymous Monk on Dec 02, 2003 at 00:59 UTC
    Yea, I knew that $a and $b are not good choices, from writing sort code. I don't do that in my real code. But you guys are right to point that out when you see it of course.

    thanks