With AoAs something like:
my $ar = [ [ 'HEAD_goes_here', 'BODY_here' ],
[ 'FOOT', 'FOOT', 'FOOT', 'FOOT' ]
];
written as a template with the literals as documentation. After the not-finding and the not-thinking,
I wrote a sub to walk AoAs and extract the references to the scalar elements. Doing it
by hand, one might write:
my $scalars_flattened = [ \$ar->[0][0], \$ar->[0][1],
\$ar->[1][0], \$ar->[1][1], \$ar->[1][2], \$ar->[1][3] ];
Its gist:
my @flat = @{$_[0]};
while ( List::Util::any { 'ARRAY' eq ref $_ } @flat ) {
@flat = map { 'ARRAY' eq ref $_ ? \(@$_) : \$_ } @flat;
@flat = map { 'REF' eq ref $_ ? $$_ : $_ } @flat;
}
Fortunately only in testing did I find the less helpfully shaped templates like:
$ar = [ 'HEAD', 'BODY', [ 'FOOT', 'FOOT', 'FOOT', 'FOOT'], ];
I would die if I had one like that.
Be well,
rir