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


In reply to "Nonliteral literal" is just an expression. by rir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.