in reply to Will "$_[0]=shift" always resolve shift first?
As you can see from the listing in perlop, the assignment operator ("=") has right associativity, which means that the right side is evaluated before the left side.
Incidentally, this is the very reason that the following common idiom works as you expect:
$x = $y = 42;
Had "=" its left side evaluated first, the 42 would not make it into the $y variable, which would lead to code breakage all over the planet ;)
Update: Hm, scratch that, I think I confused a few terms. The associativity tells us how the statement gets parsed, not how it gets executed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Will "$_[0]=shift" always resolve shift first?
by ikegami (Patriarch) on Sep 08, 2008 at 22:00 UTC | |
|
Re^2: Will "$_[0]=shift" always resolve shift first?
by GrandFather (Saint) on Sep 08, 2008 at 23:55 UTC | |
by ikegami (Patriarch) on Sep 09, 2008 at 00:16 UTC | |
by GrandFather (Saint) on Sep 09, 2008 at 01:14 UTC | |
by ikegami (Patriarch) on Sep 09, 2008 at 01:57 UTC | |
by GrandFather (Saint) on Sep 09, 2008 at 03:16 UTC |