Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
When I run this code:
it only displays the last row in the data.txt file. How can I get it to ready each line and create an array for each line? How would a has be used here?open(FILE, "data.txt"); #opens data.txt in read-mode while(<FILE>){ #reads line by line from FILE which i +s the filehandle for data.txt chomp; @data = split(/,/,$_); } close FILE; #close the file. print "test:\t$_\n" foreach (@data);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with array
by Hot Pastrami (Monk) on Mar 14, 2001 at 04:22 UTC | |
|
Re: problem with array
by lhoward (Vicar) on Mar 14, 2001 at 04:24 UTC | |
|
Re: problem with array
by mkmcconn (Chaplain) on Mar 14, 2001 at 06:31 UTC | |
|
Re: problem with array
by jeroenes (Priest) on Mar 14, 2001 at 17:57 UTC | |
by Anonymous Monk on Mar 15, 2001 at 01:16 UTC | |
by jeroenes (Priest) on Mar 15, 2001 at 02:54 UTC | |
|
Re: problem with array
by AgentM (Curate) on Mar 14, 2001 at 04:24 UTC |