Is there such a thing as a list in scalar context?

前端 未结 6 1632
孤独总比滥情好
孤独总比滥情好 2020-12-11 16:52
my $mind = ( \'a\', \'little\', \'confused\' );

And it\'s because perldoc perlfaq4 explains the line above as follows (emphasis added):

6条回答
  •  感情败类
    2020-12-11 17:30

    I agree with you and with perlfaq4. To quote perldata, which is probably the definitive documentation on this point:

    In a context not requiring a list value, the value of what appears to be a list literal is simply the value of the final element, as with the C comma operator.

    (emphasis mine).

    That said, ikegami is entitled to use whatever terminology (s)he wants. Different people think of different language constructs in different terms, and as long as the end results are the same, I don't think it matters if their terminology differs from that in the documentation. (It's not a great idea to insist on idiosyncratic terminology in a public forum, though!)

提交回复
热议问题