From: Peter Bailey Date: 2006-11-08T00:54:43+09:00 Subject: Why am I getting this string error? Can someone explain to me why I'm getting the error below for this part of a script? It doesn't seem to like line 24, the scan line, but, I've got this same code being used for other needs and it doesn't complain at all there. Thanks, Peter ... 20 Dir.glob("*.ps").each do |psfile| 21 $filetime = File.ctime(psfile) 22 $filetime = $filetime.to_s.gsub!(/ -.*$/, "") 23 file_contents = File.read(psfile) 24 file_contents.scan(/\%\%Pages: (\d{1,5})[ ]+\n/) do 25 totalpages = $1 26 if (totalpages.to_i % 2) !=0 then 27 totalpages = totalpages.to_i + 1 28 file_contents << "\%\%Blank page for Asura.\n\%\%Page: 29 #{totalpages.to_i}\nshowpage\n" 30 File.open(psfile, "w") { |f| f.print file_contents } 31 FileUtils.touch(psfile) 32 end ... getting this error: >rubyw indexpagecounts_6x9.rbw indexpagecounts_6x9.rbw:24:in `scan': string modified (RuntimeError) from indexpagecounts_6x9.rbw:24 from indexpagecounts_6x9.rbw:20:in `each' from indexpagecounts_6x9.rbw:20 >Exit code: 1 -- Posted via http://www.ruby-forum.com/.