From: Kurt Euler Date: 2002-06-09T16:08:47+09:00 Subject: Possible memory bug in Ruby? I'm stumped! All- The code as written after the dashed line way below (with file name t7.rb) correctly inserts the contents of file "intro_subtemplate.txt" into a template file during each iteration, resulting in the creation of some 189 identical but differently named files in directory "./output". (There are 189 filenames in the 189 rows in file "packages.txt".) However, if I uncomment the two lines starting at "insertb", only 171 files are created, then the program stops with the following message: t7.rb:6:in 'initialize': Invalid argument - "./input/intro_subtemplate.txt" (Errno::EINVAL) from t7.rb:6:in 'new' from t7.rb:6 from t7.rb:2in 'foreach' from t7.rb:2 Interestingly, If I then uncomment the two lines beginning at "insertc", only 128 files are created before the program stops with the a similar message but specifying a different code line from the just-uncommented lines: t7.rb:15:in 'initialize': Invalid argument - "./output/SOL_BroadbandManager_6.2_SP1" (Errno::EINVAL) from t7.rb:15:in 'new' from t7.rb:15 from t7.rb:2in 'foreach' from t7.rb:2 Is this the result of some type of memory leak or improper programming? (Note: I'll ultimatelly have some 6 or 8 files that need to be inserted into each copy of the "main_readme_template" at the position of various tags in this template.) Please help, I'm stumped! Thanks in advance!!! -Kurt Euler (I'm using Ruby 1.67) File t7.rb: -------------------------------------------------------------- content = File.new("./input/main_readme_template.txt").read IO.foreach("./input/packages.txt") { |x| field = x.chop.split(':') content2 = content inserta = File.new("./input/intro_subtemplate.txt").read content2.gsub!(//, inserta) #insertb = File.new("./input/install_unix_subtemplate.txt").read #content2.gsub!(//, insertb) #insertc = File.new("./input/files_changed_sp_num-1_subtemplate.txt").read #content2.gsub!(//, insertc) File.new("./output/"+field[0],"w+").write(content2) puts field[0] }