The while... bit splits each line up and puts the resulting array into an element of @array.

split with no arguments takes a line from $_ and splits it on whitespace (e.g, /\s+/) after disregarding leading spaces. So, that creates the 'inner' array from each line (each word in the line is 1 element), and then the 'outer' array is created with each line as an element. So,

This is a test. This is line #2
would be read in like this:
$array[0][0] = "This"; $array[0][1] = "is"; $array[0][2] = "a"; $array[0][3] = "test"; $array[1][0] = "This"; $array[1][1] = "is"; $array[1][2] = "line"; $array[1][3] = "#2";

And of course, you are going to have to change this based on your data file's structure.


In reply to RE: RE: Re: Inputing info into Nested Arrays by Cirollo
in thread Inputing info into Nested Arrays by She-wolf

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.