From: Ilmari Heikkinen Date: 2006-04-07T00:28:18+09:00 Subject: Re: Basic input/output question Hi, On 4/6/06, 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.">> Thank you very much.> If your files aren't very large, the simple way is to: data = File.read("text1.txt")result_data = do_stuff_to( data )# open text2.txt in "w"rite modeFile.open("text2.txt", "w"){|text2| text2.write(result_data)}