It's short, elegant, and gets the job done.Sounds like typical Perl to me.
Will it confuse peopleNo doubt it will confuse people. It's almost impossible to write some code that doesn't confuse people. And there will always be people (and unfortunally, relatively more of them can be found on perlmonks) who try to enforce some arbitrary rules on how people should code because it otherwise confuses them (although they try to claim it confuses everyone else as well). Example where this happens:
is it just bad practice in general to rely on the order of evaluations?Not at all. It's only bad practice to rely on the order of evaluation if the order isn't defined. But the order is defined in your case. From perlop:
And then, skipping a paragraph, it defines -> to be left associative.Operator associativity defines what happens if a sequence of the same operators is used one after another: whether the evaluator will evalu- ate the left operations first or the right. For example, in "8 - 4 - 2", subtraction is left associative so Perl evaluates the expression left to right. "8 - 4" is evaluated first making the expression "4 - 2 == 2" and not "8 - 2 == 6".
In reply to Re: One line accessor method style.
by Anonymous Monk
in thread One line accessor method style.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |