|> Lists don't return their length in scalar context
With "goatse" it's a list _assignment_ = which in scalar context returns the number of list elements assigned.
But this was a scalar assignment.
> my $x = ('a', 'b', 'c');
The LHS of the assignment operator decides about the context.
An example of scalar context of list context of assignment is
while ( ($v,$k) = each %h )
It will terminate as soon as each returns an empty list, not when the lists last element (here $k) is undef.
PS: you replied to yourself twice.
I think analyzing the op-tree helps understanding the mechanism
lanx@nc10-ubuntu:~/org$ perl -MO=Terse -e'$x= ()=qw(a,b)'
LISTOP (0x9bd0fe0) leave 
OP (0x9be01e8) enter
COP (0x9bb8860) nextstate
BINOP (0x9b3ca48) sassign
BINOP (0x9b21a58) aassign 
UNOP (0x9b218c0) null 
OP (0x9be3e40) pushmark
SVOP (0x9c14638) const  PV (0x9b1dee0) "a,b"
UNOP (0x9c14598) null 
OP (0x9b19820) pushmark
OP (0x9b3c980) stub
UNOP (0x9be8630) null 
PADOP (0x9b21940) gvsv GV (0x9b1dec0) *x
-e syntax OK
(don't blame me for Larry's decision to call a list assignment aassign)
You see assignment BINOP is like a function called with arguments (RHS,LHS) and RHS is evaluated according to LHS context and assigned to LHS. (thats decided a compile time)
The RHS of the first BINOP is the second BINOP, not a list.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||