From: Daniel Schierbeck Date: 2005-11-20T19:47:23+09:00 Subject: Re: problem with .each do Lady Michelle Bhaal wrote: > Hiya. The book does things this way, so why doesn't it work for me? > What's going on? > > def fromWeb(site, url) > # get data from website > h = Net::HTTP.new(site, 80) > resp, data=h.get(url, nil) > > # process data > data.each do <- point of second error > |line| Try `data.each do |line|'. It may be the line break that's causing trouble. > if /DGM_navigation/ =~ line do > # decode page lineage > step=Array.new > astep, line = getNextWord(line) > while astep != nil > step.push(astep) > astep, line = getNextWord(line) > end > puts "Page Lineage" > step.each do > |astep| Same here. > step.each do > put " " > end > puts astep > end > end # end DGM_naviation > end # end data.each <- gets "undefined method 'line'", from the > second error point above > end # end def fromWeb > > def getNextWord(line) > i1 = />\w+ > string_wanted=$&[1..$&.length-1] > string_remaining=$' > return string_wanted, string_remaining > end > > Cheers, Daniel