Dears, I have two .txt files. I read both into arrays and I would like
to match the lines containing the same words. The words should come from
a separate text (input.txt) file. This is what I have done:

# Open the file - get a file handle
test1 = File.new "OpenSystemHO.txt"
test2 = File.new "OpenSystemDR.txt"

myArray= Array.new
 myArray=[]  # start with an empty array
  test1.each_line {|line|
    myArray.push line
 }

myArray2= Array.new
 myArray2=[]  # start with an empty array
  test2.each_line {|line|
    myArray2.push line
 }

while interest = gets

myArray.each {|e| print e,"\n" if e.include?(interest)}
myArray2.each {|e2| print "*",e2,"\n" if e2.include?(interest)}
 end

Problem 1: if I have only 1 word in the text file to search it works
fine but if I have two, searching only the second (last) one.

Problem 2: how can I write one file from one array one from the other
and not grouping the result of array1 and array2.

thank you in adavance: Szabolcs

Attachments:
http://www.ruby-forum.com/attachment/4485/input.txt

-- 
Posted via http://www.ruby-forum.com/.