loading data from file into 2d array

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-05-02T00:32:25Z Indexed on 2010/05/02 0:37 UTC
Read the original article Hit count: 372

Filed under:
|
|

I am just starting with perl and would like some help with arrays please. I am reading lines from a data file and splitting the line into fields:

open (INFILE, $infile);
do {
my $linedata = <INFILE>;
my @data= split ',',$linedata;
....
} until eof;

I then want to store the individual field values (in @data) in and array so that the array looks like the input data file ie, the first "row" of the array contains the first line of data from INFILE etc.

Each line of data from the infile contains 4 values, x,y,z and w and once the data are all in the array, I have to pass the array into another program which reads the x,y,z,w and displays the w value on a screen at the point determined by the x,y,z value. I can not pas the data to the other program on a row-by-row basis as the program expects the data to in a 2d matrtix format. Any help greatly appreciated. Chris

© Stack Overflow or respective owner

Related posts about array

Related posts about io