From: Thomas Luedeke Date: 2008-07-31T05:07:21+09:00 Subject: Re: Loop behavior not understood (newbie) Gregory Brown wrote: > On Wed, Jul 30, 2008 at 3:33 PM, Thomas Luedeke > wrote: > >> If I change "detailedModelModified.puts line" to "puts line" in my >> coding, it works as intended. The problem is in the print to the >> detailedModelModified file. >> >> I'll try your version and see if it works in my coding. Be back in a >> minute. > > Actually, I didn't notice your nested ifs. This should be equivalent > > check_disabled = false > > File.open( "detailed_model_mod", "w" ) do |mod| > File.foreach("detailed_model") do |line| > if check_disabled || line =~ /^\s*[\*]/ > mod.puts(line) > check_disabled = true if line =~ /^\s*41/ > end > end > end OK, your version seems to work. I'm confused, however, because I don't see the functional difference between your coding and mine. What was the error in my coding previously?? Why did it not know how to print to the intended file?? -- Posted via http://www.ruby-forum.com/.