in reply to ||= oddity
What is interesting is that this prints x:@bar = (1,2,3) unless @bar;
So perhaps the RHS is not being interpreted as a list constructor but as a sequence of expressions whose value is the last expression. That would explain this behavior:$bar ||= (1,2,'x'); print $bar, "\n";
So it appears that ($a, $b) on the LHS is being interpreted as a sequence (not list constructor) of l-values whose value is the last (l-value) expression. However, in this case:my ($a, $b); ($a, $b) ||= ('a', 'b', 'c'); # $a unchanged, $b <- 'c' ($a, $b) ||= (1, 2, 3); # $a unchanged, $b unchanged $b = (1, 2, 'x'); # $b <- 'x' $a ||= (3, 4, 5); # $a <- 5
we have list constructors on both the LHS and RHS.($a, $b) = (7,8,9); # $a <- 7, $b <- 8
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ||= oddity
by kyle (Abbot) on May 28, 2008 at 20:47 UTC | |
by ruzam (Curate) on May 29, 2008 at 13:47 UTC | |
by ikegami (Patriarch) on Jun 24, 2008 at 20:22 UTC | |
|
Re^2: ||= oddity
by chromatic (Archbishop) on May 28, 2008 at 21:10 UTC |