in reply to Selecting Ranges of 2-Dimensional Data

FWIW:

it's possible to alias single array elements

use warnings; use strict; use Data::Dump qw/pp/; my @a= ('a','b','c','d'); *b = \$a[1]; $b ="X"; pp @a

("a", "X", "c", "d")

But wasn't able yet to bind the alias to another array element.

But I seem to remember seeing it done in the past ...°

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

update

°) yep, see arr_alias() in Re: Selecting Ranges of 2-Dimensional Data (array of aliases)

Replies are listed 'Best First'.
Re^2: Selecting Ranges of 2-Dimensional Data
by haukex (Archbishop) on Oct 26, 2018 at 15:53 UTC

    The following hack passes the tests in the root node:

    use Data::Alias; sub getsubset { my $d = shift; alias my @x = @{$$d[1]}[1,2]; alias my @y = @{$$d[2]}[1,2]; return [ \@x, \@y ]; }
      yeah, but I meant without Data::Alias and just with a standard *glob mechanism.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Array elements aren't globs, so no.

        It is possible to create an array of aliases without an external module, though.

        sub getsubset { my $d = shift; return [ sub { \@_ }->( @{$$d[1]}[1,2] ), sub { \@_ }->( @{$$d[2]}[1,2] ), ]; }