A slight improvement upon Happy-the-monk's reply. You see, you still need to know how to access the data. For that you can read perlreftut, perldsc and perllol. Then come back and look through my code.

#!/usr/bin/perl use strict; use warnings; my @data; open(DAT, '<', 'test.txt') or die $!; while(<DAT>) { chomp; push @data, [ split( /,/ ) ]; } close(DAT); for my $row ( 0 .. $#data ) { # iterate over each row by index for my $column ( 0 .. $#{$data[$row]} ) { # iterate over each column + by index print "row $row, column $column: $data[$row][$column]\n"; # displa +y using the notation from the Arrow Rule } } # now let's just print the data in the 1st row, 1st column (zero based + of course) print $data[1][1],"\n"; # valid, see above print $data[1]->[1],"\n"; # also valid, Rule 2 print ${$data[1]}[1],"\n"; # also valid, Rule 1

In reply to Re: Splitting text into arrays by Mr. Muskrat
in thread Splitting text into arrays by perl_seeker

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.