From: Jeremy Bopp Date: 2011-02-03T05:52:14+09:00 Subject: Re: Combining two file write commands On 2/2/2011 2:46 PM, Bob Hatch wrote: > First, let me think everyone for the wonderful advice, especially, > Jeremy. I would like to combine the following statements into one > statement. Any ideas, or do I need to keep them separate? > > outfile.write(line) if line =~ search_text > outfile2.write(line2) unless line2 =~ search_text2 Each of these writes is executed under separate conditions, so they need to be kept separate. The writes are also called on different objects, so there is no way to unify them into a single write call in any case. Assuming your conditionals could be unified, the best you could do is something like this: if line =~ search_text then outfile.write(line) outfile2.write(line2) end -Jeremy