On 12.06.2010 04:38, Phil Richards wrote: > Several scripts that used to work now don't. I had not used ruby or any > of > these scripts for several months. In the meantime i upgraded vista to > windows 7 (clean install) and decided to install 1.9.1 rather than the > 1.8.7 i used previously. > > And now here's the problem i have: > > f = open("http... > webpage = f.read > .. > dump = webpage.sub(%r{<body.*?>(.*?)... > .. > # process the rest line-by-line > dump.each do |eachline| # this line produces this error: > .. :in `block in<main>': undefined method `each' for > #<String:0x1f3f620> (NoMethodError) > > I guess its telling me dump is a string and you can't do "string".each > But i don't understand why this--and several similar--scripts DID WORK > with Ruby 1.8.7 So 1.8.7 would "split up" dump at every newline (CR/LF) > but 1.9.1 will not...??? > > Can someone tell me what's going on, and what i should try to get these > to work > with 1.9.1? You just need to replace #each with #each_line and be done. I believe the background of this is that 1.9 tries do it a bit better than 1.8 which assumed every String is an Enumerable of lines instead of characters which would be more natural. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/