Okay, obviously I'm about to learn something important here. Because, at first glance, it sounds like you've just asserted two mutually exclusive things.

  1. Assignment always evaluates arguments in list context.
  2. Scalar and list assignment provide different contexts.

Reading further up the comment chain, you are saying that the parens on the left change which assignment operation is used and that is what determines the context. Do I understand this correctly?

I went to Programming Perl (3rd edition) to check what I remembered. In Chapter 3, in the section "Assignment Operators", it explicitly says:

List assignment may be done only with the plain assignment operator, =. In list context, list assignment returns the list of new values just as scalar assignment does.

This talks about the context in which = is evaluated, but says nothing about how the arguments are evaluated. This may be the source of my (and others) confusion.

So, just to be clear, you are saying that the parens on the left of the =, just like a list on the left, trigger the use of the list assignment, correct? I'm still a little fuzzy on how that makes both sides always evaluate in list context.

Bear with me on this, I feel like I'm missing something fundamental. I've been working with Perl for a very long time now and thought I understood this point.

G. Wade

In reply to Re^12: chopping a string into slices - is there a more elegant way to do it? by gwadej
in thread chopping a string into slices - is there a more elegant way to do it? by rovf

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.