From: Mike Fletcher Date: 2006-11-04T04:34:06+09:00 Subject: Re: Unable to write to file... (example from "pickaxe book", Li Chen wrote: > Mike Fletcher wrote: >> John Maclean wrote: >>> Thanks! The light shines. So how can i -write- to a file using the code >>> below as an example? >> >> Open a file for writing >> >> File.open( "infile", "r" ) | in | >> File.open( "outfile", "w" ) | out | >> while line = in.gets >> out.print line >> end >> end >> end >> >> See the docs for IO which explain all the mode flags ("r", "w", "a", >> etc.). > > Do you think this script work? As is no (I blame lack of caffeine and/or sleep); but with "do" inserted in the right two places and the reserved word "in" replaced with something that's not a reserved word ( say "inf" ) it works just fine. One should take all example code posted in haste to mailing lists with a grain of salt. -- Posted via http://www.ruby-forum.com/.