"be consistent" | |
PerlMonks |
Re: Will "$_[0]=shift" always resolve shift first?by betterworld (Curate) |
on Sep 08, 2008 at 23:41 UTC ( [id://709917]=note: print w/replies, xml ) | Need Help?? |
I've found the following code in Perl 5.10.0's testsuite in t/op/local.t:
Now, I daresay (and I hope that my head is clearer than when I wrote my last node) that this only works if "=" evaluates its right-hand operand first. The important line is the one with the second local. As a run-time operator, local() effectively sets its operand ($a[2] in this case) to an undefined value. But then this new value will be set to the value of $a[2] before local was executed. This would not work the other way round. Apart from this extract, local.t contains more similar tests. In a nutshell: Even though I could not find any hints in the documentation, the test suite suggests that kyle's coworker's code is reliable.
In Section
Seekers of Perl Wisdom
|
|