in reply to Re: problem with array
in thread problem with array

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; push(@data,split(/,/,$_)); } close FILE; #close the file. print "$_\n" foreach (@data);



Now that I've read the comma delimited rows, split the values, and printed them out, I'd like to only get the middle value and assign it as $co. Basically, how do I just pull the first, second, or third value based on my preference?

Replies are listed 'Best First'.
Re: Re: Re: problem with array
by jeroenes (Priest) on Mar 15, 2001 at 02:54 UTC
    Hmmmm... either I don't understand your question or you'd better have a good ponder at them docs. Do you mean:
    push @data, [split /,/]->[$col] for (<FILE>);
    ?

    Jeroen
    "We are not alone"(FZ)