Hi all,
I'm trying to make a list of lists. The main list will have 926
sublists. Each sublist will have 7 items. I organized the data into a very
nice text file all formatted the way (I thought?) I needed it to be. The text
file looks like so:
a, b, c, d, e, f, g
h, i, j, k, l, m, n
o, p, q, r, s, t, u
v, w, ...
My code to get this into a 2-dimensional list starts by opening the text
file. Then I have a line
@RawData = <FILE>;
At this point I have a 1-dimensional list, 926 items long, where each
item is a string, (each of those strings being 7 numbers separated by commas).
I want to convert each of those 926 strings to lists. That way, on this new
list I can get at individual numbers easily by say,
@FinishedData[x][y]
So I do the following:
for($z = 0; $z < 926; $z +=1) {
@instance = ($RawData[$z]);
push(@FinishedData, [ @instance ]);
}
But this doesn't work. @FinishedData[x][y] is considered an
uninitialized value. Trying to debug, it seemed to me that @FinishedData
never became 2D because @instance never became 1D. I get a scalar quantity no
different than $RawData[$z]. Why should this be? If I were to write:
@NewRow = (h, i, j, k, l, m, n);
push(@Finished Data, [ @NewRow ]);
it would work fine. (@NewRow would be a list, and (after doing this
multiple times) @FinishedData would be a 2D list). But I have 926 'new rows'
which I don't want to type out as code - they're already in a text file. Why
can't I just replace the (h, i, j, k, l, m, n) with a variable and loop?
Fred Kittelmann
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates
starting at 1ยข/min.