The short version: Parentheses create a list when the context is indeterminant. Always? Sometimes? I don't know, I just have the wwimery
1 down pretty well.
$c = ( () = /\w+/g );
This is a special case documented in perlop under
Assignment Operators and, I think, perldata documents
() as the literal null list. Your description seems correct to me.
() = ("head", "tail");
@ar = ( "head", "tail");
($head, $tail) = ( "head", "tail" );
Lead us, in notational way, to accepting or expecting the behaviour of
($head) = ( "head", "tail" );
but I don't think I've seen this documented. Here the parenthesis do make a list of the assignment's LHS. It is too easy to think that the LHS of an assignment operation is effected by the enclosing context, when we should realize that the context of an assignment op's LHS is self-determinant. That is the similarity with the repetition operator.
Be well,
Rob
1 Write what it means.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.