in reply to Re: Re: dereferencing in a list context
in thread dereferencing in a list context

Limbic~Region, your code:

@m = (\@a, \@b, \@c);

does the exact same thing (less tersely) as the original node's code:

@m = \(@a, @b, @c)

which the original author appeared dissatisfied with. So I don't think you've given what was desired.

The fact that \(...) 'distributes' the make-reference operation across the "list" of comma-separated items inside of the parens instead of distributing across the "list" of scalar values that would result if the backslash weren't there, is a particularly surprising (perhaps ingenious, perhaps something else) feature of Perl's backslash operator. It certainly breaks the usual patterns that many have come to expect from Perl. I see how it is useful as syntactic sugar, but also how it suprises and confuses people.

Note that if you want to distribute the make-reference operation across the "list" of scalar values, you can use:

my @listOfSVs = map \$_, @a, @b, @c;

[ And I note that this is now the perfect example to use when people try to tell me exactly what a "list" in Perl is or isn't, since it contrasts two of the most commonly assumed definitions of "list" (when in fact, the term "list" isn't tightly defined in Perl, but can mean all kinds of different lists of thing, just like in regular English). ]

- tye