From: Sebastian Hungerecker Date: 2007-12-14T01:44:07+09:00 Subject: Re: pulling out a specfic feild from a line Peter Loftus wrote: > arr = Array.new > i = 0 > File.foreach(example.txt) do |line| >    arr[i] = line >    i += 1 > end arr = File.readlines("example.txt") Does the same as the code above, but is far more compact. > arr.each do |item| > if (arr.to_s.split("\t")[2] = "example 3") >   puts "found it" > end arr.to_s will give you the whole content of the file. You want to use item. arr.map! {|line| line.split("\t")[2]} arr.each_with_index do |field, i| if field puts "Found field #{field} in line #{i}" else puts "No third field in line #{i}" end end HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826