Konovalov, Vadim <vadim.konovalov <at> alcatel-lucent.com> writes: >>> $ perl -E '$a = $b = "abc100"; 0 + $b; say $a; say $b; >>> $a ++; $b ++; say $a; say $b' >> >>That is a nasty one. Surely the expression 0 + $b should not >>mutate the value of $b. > perldoc Scalar::Util > >dualvar section? Thanks for the pointer. I hadn't read that although I was aware of the common 'zero but true' trick. However the existence of dual-valued variables isn't the issue here. The point is that just evaluating the expression ($b + 0) in some other code, even if you do not assign the result to $b or try to change $b in any way, has the unexpected side-effect of changing the value stored in $b. That can't be right. -- Ed Avis <eda@waniasset.com>Thread Previous | Thread Next