Given your clarifications, this change to Abigail's code may work better for you:
#!/your/perl/here use strict; use warnings; my @accounts = ("A x1 B y1 C z1 D v1 E w1 F", "A x2 B y2 C zzz2 D v2 E w2 F", "A x3 B y3 C z3 D v3 E w3 F", "A x4 B y4 C D v4 E wwww4 F", # note change to C..D "A x5 B y5 C z5 D v5 E w5 F", "A x6 B y6 C z6 D v6 E F"); my @fields = ("A", "B", "C", "D", "E", "F"); my $regex = join '\s+(\w*)\s+', @fields; my @accounts_2 = map {[/$regex/]} @accounts; __END__
The code map {[/$regex/]} @accounts creates an anonymous array for each element of @accounts.

And with the debugger:
DB<3> x @accounts_2 0 ARRAY(0x1ca7364) 0 'x1' 1 'y1' 2 'z1' 3 'v1' 4 'w1' 1 ARRAY(0x1ca2b30) 0 'x2' 1 'y2' 2 'zzz2' 3 'v2' 4 'w2' 2 ARRAY(0x1cbe7cc) 0 'x3' 1 'y3' 2 'z3' 3 'v3' 4 'w3' 3 ARRAY(0x1cbe88c) 0 'x4' 1 'y4' 2 '' # reflects data change above 3 'v4' 4 'wwww4' 4 ARRAY(0x1cbf97c) 0 'x5' 1 'y5' 2 'z5' 3 'v5' 4 'w5' 5 ARRAY(0x1cbe8bc) 0 'x6' 1 'y6' 2 'z6' 3 'v6' 4 ''
Note that if the stuff between field markers resembles the field markers, this won't work. Also, for pathological inputs, backtracking is a real issue.

-QM

In reply to Re: Re: Re: Re: Array in Array by QM
in thread Array in Array by nylon

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.