in reply to Re^2: There's scalar(), but no list(). Perl could need one for rare but reasonable use
in thread There's scalar(), but no list(). Perl could need one for rare but reasonable use
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.
It's possible to return a scalar in list context (since a single scalar is zero or more scalars), which is why scalar exists.
It's not possible to return a list in scalar context (since zero or more scalars isn't a scalar), which is why list doesn't exist.
Adding list would not improve symmetry or robustness; it would just lie about what you are doing. If you want a function that returns the last scalar of a list or scalar, list is a shitty name.