The biggest problem with list (or rather its name) is that it perpetuates the incorrect knowledge that operators in scalar context return a list which is then coerced to return its last element. I'd rather have lastval() and count().
Nothing stops a CPAN module from providing these. Like you said, they're rarely needed.
By the way, the caller can grab the correct value from your example using:
my $x = ( f(...) )[-1]; # Last value my $x = () = f(...); # Count
In both cases, f is called in list context.
In reply to Re: There's scalar(), but no list(). Perl could need one for rare but reasonable use
by ikegami
in thread There's scalar(), but no list(). Perl could need one for rare but reasonable use
by flowdy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |