From: Damjan Rems Date: 2008-03-06T16:24:03+09:00 Subject: Re: Too many open files on OpenBSD Yukihiro Matsumoto wrote: > Hi, > > It seems you recursively call parse, which keep files opened. How > about reading whole file content in a string by File.read, then call > each_line on the string? E.g. > > def parse() > File.read(@path).each_line do |line| > line =~ /^(.*?) (.*)/ > > .... > end > end Or even better: def parse() lines = File.open(@path) {|f| f.read} lines.each_line do |line| line =~ /^(.*?) (.*)/ .... end end With File.open file gets closed automaticly after block is processed. by TheR -- Posted via http://www.ruby-forum.com/.