David Cantrell wrote:
If I have nest maps, like so ...
map { map { foo } bar }
is there any (elegant) way of getting at the outer map's idea of what $_
is from within the inner map? I'd rather not use a temporary variable
if at all possible.
How about an alias instead? For example:
map { local *outer = \$_; map { foo $outer, $_ } bar } @list;
Of course, in Perl 6 it's trivial:
map -> $outer { map { foo $outer, $_ } bar } @list;
or:
map -> $outer { map -> $inner { foo $outer, $inner } bar } @list;
or:
map { map { foo $OUTER::_, $_ } bar } @list;
or:
map { my $outer := $_; map { foo $outer, $_ } bar } @list;
Damian