Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

(tye)Re: Possible pitfall with Slices

by tye (Sage)
on Nov 07, 2000 at 03:19 UTC ( #40279=note: print w/replies, xml ) Need Help??

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")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://40279]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-03-18 16:29 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.