http://www.perlmonks.org?node_id=40279


in reply to Possible pitfall with Slices

I can see points on both sides here. I like a middle ground of a warning for assigning a scalar to a list of more than one element. So no behavior would be changed but under "-w", the following would solicit a warning:

( $x, $y )= $z; @array[1,2]= $z; @hash{qw(a,b)}= $z; @hash{@array}= $z x @array; # unless 1==@array
but the following would not:
( $x )= $z; ( $x, $y )= ( $z ); @array= $z; # sorry, I think this has to remain unwarned @array[1]= $z; # but already has its own warning @array[1,2]= ( $z ); @hash{qw(a,b)}= ( $z ); @hash{@array}= ( $z ) x @array;
Note how this would catch the mistake a senior monk made in this very thread.

        - tye (but my friends call me "Tye")