From: Yukihiro Matsumoto Date: 2008-03-06T10:08:24+09:00 Subject: Re: Too many open files on OpenBSD Hi, In message "Re: Too many open files on OpenBSD" on Thu, 6 Mar 2008 09:32:58 +0900, Edd Barrett writes: |This is the error I am stuck with: | |---8<--- |./tlpsrcnode.rb:19:in `initialize': Too many open files - |/home/tl/tl/Master/tlpkg/tlpsrc/wordcount.tlpsrc (Errno::EMFILE) | from ./tlpsrcnode.rb:19:in `new' | from ./tlpsrcnode.rb:19:in `parse' | from ./tlpsrcnode.rb:30:in `parse' | from ./tlpsrcnode.rb:20:in `each' | from ./tlpsrcnode.rb:20:in `parse' | from ./tlpsrcnode.rb:30:in `parse' | from ./tlpsrcnode.rb:20:in `each' | from ./tlpsrcnode.rb:20:in `parse' | ... 3055 levels... | from ./tlpsrcnode.rb:20:in `each' | from ./tlpsrcnode.rb:20:in `parse' | from ./roottlpsrcnode.rb:53:in `startParse' | from ./rbmfsplit:54 |---8<--- 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 -- matz.