why it would give me bbb, the last element ?
Because the Comma Operator in scalar context "evaluates its left argument, throws that value away, then evaluates its right argument and returns that value." See also arrays and lists, hmmm (one thread of many)
(choroba beat me to it ;-) )
Update: I just wanted to pick up on the node title:
assigning an array to scalar
('111','222','aaa','bbb') isn't an array, in this form it's a literal list. While you obviously use lists to populate arrays, arrays and literal lists behave differently in different contexts. For example, an array in scalar context returns its size, whereas a list returns its last value (due to the way the comma operator works, as I said above).
In reply to Re: The behavior when assigning an array to scalar? (updated)
by haukex
in thread The behavior when assigning an array to scalar?
by fgg1991
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |