Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

(tye)Re: Possible pitfall with Slices

by tye (Cardinal)
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")


Comment on (tye)Re: Possible pitfall with Slices
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-09-23 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (216 votes), past polls