I'm not understanding how to create a multidimensional array by reading lines from a file.
So say I have a file like this:
0 1 2 3
4 5 6 7
8 9 10 11
With lines of numbers separated by tabs.
I would have something like this to read the lines from the file and put each line into the array:
my @Array;
while (<>) {
chomp;
push @Array, "$_";
}
So that results in an array with 3 strings stored in it, tabs and all. But what I really want is to store each number as a separate element in the array so I can refer to each number using references such as @Array[0][1], @Array[2][3], etc. What do I do next to convert it to this form? Or perhaps even better to put it in the right form in the first place?
I tried some things with split /\t/ but wasn't able to get it right.
-Lauren
So say I have a file like this:
0 1 2 3
4 5 6 7
8 9 10 11
With lines of numbers separated by tabs.
I would have something like this to read the lines from the file and put each line into the array:
my @Array;
while (<>) {
chomp;
push @Array, "$_";
}
So that results in an array with 3 strings stored in it, tabs and all. But what I really want is to store each number as a separate element in the array so I can refer to each number using references such as @Array[0][1], @Array[2][3], etc. What do I do next to convert it to this form? Or perhaps even better to put it in the right form in the first place?
I tried some things with split /\t/ but wasn't able to get it right.
-Lauren