Some of these weirdnesses will go away in Perl 6. It is still true that = will take its context from the left side, while += will enforce scalar context on both sides. What will change, however, is that any list-producing operator that returns its last value in scalar context in Perl 5 will instead produce a list reference in Perl 6.

That means there's no C-style comma operator in Perl 6. If you want the last value of a list, subscript it with [-1]. This also means that a slice in scalar context will not return the last value as it does in Perl 5. If you try that in Perl 6, you'll get a list reference, which will fail when you try to apply a scalar operator like += to it. (Perl 6 has a way to apply scalar operators to lists, but you have to be explicit.)


In reply to Re: Fringe case slice behavior by TimToady
in thread Fringe case slice behavior by davido

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.