http://qs321.pair.com?node_id=663990


in reply to Re^2: regexp list return 5.6 vs 5.8
in thread regexp list return 5.6 vs 5.8

Very good points. I'll try to be more disciplined with test.

What about this one:

perl -le 'sub x { return qw(a b c);}; $r=x; print $r' c

This returns the plain list and that's what I want to mimic having it in an array. Arrays and list assignments have special meanings in scalar context. Slices do not. I don't know excactly where but it is documented. (I mean, it's documented that arrays and list assignments have the special scalar-context behavior, not that slices don't :-))

Update: From perldata:

If you evaluate an array in scalar context, it returns the length of the array. (Note that this is not true of lists, which return the last value, like the C comma operator
List assignment in scalar context returns the number of elements produced by the expression on the right side of the assignment:

And, as you quoted from perlsub:

A "return" statement may be used to exit a subroutine, optionally specifying the returned value, which will be evaluated in the appropriate context
use strict; use warnings; print "Just Another Perl Hacker\n";