On Wed, Oct 19, 2016 at 3:13 AM, Dave Mitchell <davem@iabyn.com> wrote: > > There's one further issue I've noticed: undef on the LHS: > > sub inc { $_++ for @_ } > > inc($a, undef ); # "Modification of a read-only value > attempted" > inc(($a, undef) = ($x, $y)); # increments $a and $y > > I think that second call to inc should pass ($a, undef) rather than > ($a, $y) to inc, and should also die with "Modification of a read-only > value attempted". Undef appears to be special in that it gets replaced with an alias to the RHS element instead of throwing a compile-time error. $ perl -le '$x=$y=1; ($a,undef) = ($x,$y) ; print "a:$a x:$x y:$y"' a:1 x:1 y:1 $ perl -le '$x=$y=1; ($a,2) = ($x,$y) ; print "a:$a x:$x y:$y"' Can't modify constant item in list assignment at -e line 1, near ") ;" Execution of -e aborted due to compilation errors.Thread Previous | Thread Next