On Wed, Jul 30, 2008 at 2:59 PM, Thomas Luedeke
<thomas.luedeke / areva.com> wrote:

> When running Ruby 1.8.7 on Eclipse, this results in nothing being
> printed to the detailed_model_mod file.  If I take out the if-end loop
> trying to pattern match the string with the leading "41", then it prints
> out fine.

Does this code give you what you want?

###

check_disabled = false

File.open( "detailed_model_mod", "w" ) do |mod|
  File.foreach("detailed_model") do |line|
    mod.puts(line) if check_disabled || line =~ /^\s*[\*]/
    check_disabled = true if line =~ /^\s*41/
  end
end

###

I *think* it does the same thing as yours, but it is sure to close the
file handles cleanly.  When I ran your code however, I was able to get
some output.

If this isn't what you want, please provide a sample data set and show
what you expect the output to be.

-greg