You are saying simply "list" to refer to what is more precisely referred to as a "list literal" (parens around a bunch of expressions separated by comma operators). This is quite often done, but you have to pay attention to the (English) context of the text to discern when. There are other places where simply "list" is used to refer to a "list of scalar values", a more general concept rather than a syntactical construct.

It is easy to get confused when reading multiple sources, some of which are saying "list" to mean "list literal" and some saying "list" to mean "list of scalar values". This is especially true because lots of the things don't conflict between those two concepts.

For example, calling a sub in "list context" certainly does not mean that the context of the call is part of a list literal. And an array stores a list of scalar values (that may have come from a list literal or not).

You seem to be struggling with trying to force features of list literals onto other types of Perl lists.

lists do not form a data type at all. Lists are a purely syntactic concept,

A list (of scalar values) is certainly a type of data in Perl. It isn't a "data type" to the point of being a type of variable (nor a type of reference). But a "list slice" can be performed on any list (of scalar values). A list is a common but ephemeral type of data in Perl (which is usually stored on the Perl stack).

When documentation talks about a 'sub' that "returns a list", it doesn't mean a 'sub' that has the 'return' keyword followed by a list literal. It means that calling the subroutine results in 0 or more scalar values being pushed onto the Perl stack and those being available at the point where the 'sub' was called. That is the type of data that the 'sub' returns to the caller. But that also only happens if the 'sub' was called from a list context.

See also Re^3: wantarray alternative (choice) and the rest of that thread.

- tye        


In reply to Re^5: There's scalar(), but no list(). Perl could need one for rare but reasonable use ("list") by tye
in thread There's scalar(), but no list(). Perl could need one for rare but reasonable use by flowdy

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.