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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |