|more useful options|
Re^5: There's scalar(), but no list(). Perl could need one for rare but reasonable use ("list")by tye (Sage)
|on Jun 17, 2014 at 21:15 UTC||Need Help??|
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.