This is an excellent application for Deparse. The -p parameter to Deparse gives you nearly as many parenthesis as perl can give you, which is useful for explainging things. I was first exposed to this trick by Brother MeowChow when I asked how in hell his .sig worked.

> perl -MO=Deparse,-p -e '$d, $e, $f = 1,2,3;' -e syntax OK ($d, $e, ($f = 1), '???', '???');
The latter arguments are thrown away because the '=' binds more tightly than the comma. If these were subroutines, they would have evaluated before being discarded.
> perl -MO=Deparse,-p -e 'print(1),print(2),print("\n");' -e syntax OK (print(1), print(2), print("\n"));
Note the parens around everything; to answer your question about why it evaluates all three terms, it is a list that gets discarded after evaluating its elements, which look like functions so they're evaluated as functions.
> perl -MO=Deparse,-p -e 'print 1, print 2, print "\n";' -e syntax OK print(1, print(2, print("\n")));
And your description was exactly right.

___ -DA > perl -MPOSIX -le '$ENV{TZ}="EST";print ctime(1000000000)' Sat Sep 8 20:46:40 2001

In reply to Re: The Comma Operator by da
in thread The Comma Operator by dsb

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.