From: Urban Hafner Date: 2001-03-07T22:35:31+09:00 Subject: [ruby-talk:12229] random chars Hello everybody, I think/hope I have some simple questions. I've writte a little program that makes a copy of itself but makes some mistakes. But I have one problem: I'd like to delete one character of the variable string, but delete! would delete this character in the whole string an not only at one position. Does anyone how it works. The shorter the expression the better. Thanks for your help, Urban ----- get = File.new($0,"r") put = File.new("#{Time.now.to_f}.rb","w") lines = get.readlines 1.upto(Kernel.rand(10)) do changeline = Kernel.rand(lines.length-1) string = lines[changeline] changechar = Kernel.rand(string.length-1) chars = Kernel.rand(127).chr 2.upto(Kernel.rand(5)) do chars = chars + Kernel.rand(127).chr end string[changechar] = chars lines[changeline] = string end lines.each {|item| put.puts(item)}