So it seems that ||= generally isn't supported in perl.$ perl -MO=Deparse -e '@bar ||= (1,2,3)' Can't modify array dereference in logical or assignment (||=) at -e li +ne 1, at EOF -e had compilation errors. @bar ||= ('???', '???', 3); $ perl -MO=Deparse -we '@foo ||= 1' Can't modify array dereference in logical or assignment (||=) at -e li +ne 1, at EOF -e had compilation errors. BEGIN { $^W = 1; } @foo ||= 1;
Update: ok, other monks explained why. ||= returns a scalar.
A quick code search shows that all examples "out there" use it only in lines that are commented out, so it seems to be a common mistake actually
In reply to Re: ||= oddity
by moritz
in thread ||= oddity
by throop
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |