From: Li Chen Date: 2006-10-10T01:40:39+09:00 Subject: Re: How to remove empty space in a string and others >> 2) I read each line from a file and split each of them into several >> fields/segments. Then I need to populate an array with one field only >> from each line. How do I do that? I know do these in Perl but have no >> idea using Ruby. > > Would need more information about your code to answer this. I have a file called array.txt with many lines and each line is a record containing different fields separated by \t. What I like to do is read the file line by line, split each line into elements, and push the element [1] from each line into a new array. # array.txt A B C 1 2 3 X Y Z ... expected output in new array [B,2,Y,...] Thanks, Li -- Posted via http://www.ruby-forum.com/.