Anonymous Monk has proposed a hash of arrays data structure, which enables you to name the sub_arrays. This is fine if you need to names these arrays. If you don't particularly need to name them, then the array of arrays structure that I outline above is just as fine for what you want to do. You could have something like this:

my @array = ([$str_1_1, $str_1-2], [$str_2_1, $str_2_2]);

It is then easy to process the strings of any subarray.

Update 08:35 UTC: added the following examples under the Perl debugger:

DB<1> @array = (["str_1_1", "str_1-2"], ["str_2_1", "str_2_2"]) DB<2> DB<2> x @array 0 ARRAY(0x253a70) 0 'str_1_1' 1 'str_1-2' 1 ARRAY(0x58f8a8) 0 'str_2_1' 1 'str_2_2' DB<3> x $array[1] 0 ARRAY(0x58f8a8) 0 'str_2_1' 1 'str_2_2' DB<4> p "$array[1][$_] \n" for 0..1 str_2_1 str_2_2

In reply to Re^2: Arrays in arrays, how to access them by Laurent_R
in thread Arrays in arrays, how to access them by viored

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.