On 09/27/2009 07:31 PM, Thairuby ->a, b {a + b} wrote:
> Is this work?
> 
> def file_process
>   @data=[]
>   File.foreach(@file) {|a_line| @data << a_line.chomp.split(/\t/)}
> end

In 1.9 you can do

@data = File.foreach(file_name).map {|l| l.chomp.split /\t/}

In 1.8 you'll need something like

require 'enumerator'
@data = File.enum_for(:foreach, file_name).map {|l| l.chomp.split /\t/}

or this which should work in both

@data = File.readlines(file_name).map {|l| l.chomp.split /\t/}

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/