From: Matthew Margolis Date: 2004-08-05T10:23:16+09:00 Subject: Re: open files in other directories Mehr, Assaph (Assaph) wrote: >The permission is on 'text/.' which is 'text' itself. > >Try: > > > >>campershash = Hash.new >>Dir.entries("text").each do |textfilename| >> >> > >Probably better expressed as Dir.glob('text/*') or Dir['text/*']. This >also ignores the "." and ".." files. > > > >> campershash["#{textfilename.chop.chop.chop.chop}"] = >> >> > >Try textfilename[0..-5] for a fixed size slice. > > > >> File.open("text/" + "#{textfilename}") { |f| f.gets(nil) } >> >> > > File.open(textfilename) if you've used glob, which preserves >the path info. > >To concatenate strings use: > "text/" + textfilename.to_s >Or better yet: > "text/#{textfilename}" > > > >>end >> >> > > > > > Thank you very much. As a ruby noob I am still learning the built in methods. I didn't even think to use glob. -Matt Margolis