A plain list, as I learned, is a comma-separated couple of values maybe in a pair of parens (just if operator precedence stipulates that). In scalar context, it shoves one value after the other into the single slot available, like it would distribute the values into the list context slots that will be discarded from tail to head unless saved in an array or in a couple of lvalue scalars (($foo, $bar) = ...). However actually implemented low-level, this at least is how it fits well into my overall knowledge of Perl. Mind the accordance to the fact that only what the last expression evaluated in a {...}-block returns is passed along the levels, and consider what $? would store from a system("longlist -of; external; commands") call, too.
But it is not that easy, there are caveats, probably more than the two I outlined in the test script. I'll try to generalize the problem: If your list consists of values equal in their kind, but you put expressions in your list that have a distinct scalar context behaviour on their own, then pray they don't happen to be evaluated in scalar context as caused by higher level in the callstack (beyond your control perhaps). This would render your list of indeed not-so-equal values overtly wrong and greedy of debugging time. If there is a means to provide scalar context, another to provide list context would not only solve a seeming lack in design (just a fan of symmetry that I am), but would also make for more robust module interfaces.
After all I've come to the conclusion that my feature request is well posted on PM. It would be ridiculous to consult p5p&co. as long as there are just two usage cases I can think of. But I'm looking forward to more cases posted by others.
In reply to Re^2: There's scalar(), but no list(). Perl could need one for rare but reasonable use
by flowdy
in thread There's scalar(), but no list(). Perl could need one for rare but reasonable use
by flowdy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |