From: Gavin Sinclair Date: 2003-09-19T10:20:47+09:00 Subject: Re: Why IO#readlines does'nt accept a Regexp? On Friday, September 19, 2003, 10:16:02 AM, Sabby wrote: > Or if word order isn't a concern: > cache = {} > IO.foreach("myfile") do |line| > line.scan(/\w+/).each {|w| cache[w] = 1} > end > words = cache.keys Or if you want to use the latest and greatest: require 'set' words = Set.new IO.foreach("myfile") do |line| line.scan(/\w+/).each { |w| words << w } end Gavin