From: James Edward Gray II Date: 2006-04-07T00:02:45+09:00 Subject: Re: Basic input/output question On Apr 6, 2006, at 9:36 AM, Peter Bailey wrote: > Hello, > I spent my $40 on "Programming Ruby," but, it seems dedicated to C > programmer rocket scientists. I work in publishing and basically I > just > need to open files, convert the data, and write the files, either > to the > same file or to another. Can someone please help me to write a simple > structure to read a file "text1.txt", do regexes and stuff in it to > convert data, and then write the output to "text2.txt." Sure, see if something like this would help you: File.open("text2.txt", "w") do |output| File.foreach("text1.txt") do |line| # change line as need here, for example: # line.sub!(/regex here/, "replacement here")... output << line end end Hope that helps. James Edward Gray II