Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(tye)Re: Possible pitfall with Slices

by tye (Sage)
on Nov 07, 2000 at 03:19 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://40279]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-28 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found