Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: The behavior when assigning an array to scalar?

by choroba (Cardinal)
on Sep 26, 2017 at 09:52 UTC ( [id://1200101]=note: print w/replies, xml ) Need Help??


in reply to The behavior when assigning an array to scalar?

That's because the comma operator in scalar context returns the second argument. See perlop for details.

Update:

Also, one interesting case is missing in your question:

my $t = '111', '222', 'aaa', 'bbb'; print $t;

It prints 111, becuase of precedence of the two operators involved, the comma and equal sign. In fact, the parentheses in the $s case were used only to change the precedence.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found