Many Perlers will censure the use of the comma as given. I'd usually avoid the construct, but if the context is simple and the core statement, the part up to if, is just a couple of "words", I'll write such.
$names++, shift if ARGV[0] eq "-l";
In scalar context, the comma operator separates expressions and returns the evaluation of the rightmost expression. Here, the first expression is evaluated and the result discarded; the side-effect of incrementing $names remains.

Update: It should be noted that no list is created by a series of comma operators in scalar context. The expressions operated on by the commas become subexpressions.

The second construct is similar but I find it odder.

$c = do { $a = 3, $b = 6 };
The same thing is happening; the assignments are in scalar context. I'd write this with a semi-colon in the middle of the do's block; one standard use of the do BLOCK is to wedge a statement or statements into a place that needs an expression. If $c were @c, my semi-colon would change the meaning.

Be well,
rir


In reply to Re: perl statements by rir
in thread perl statements by neptuneray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.