title: reading numbers into an array in ruby
body: <p>I'm trying to read numbers from a txt file into an array in ruby with some conditions. The text file input looks like this:</p>
  
  <pre>
  1 2 3 4
  5 6 7 8
  9;10 11 12
  </pre>
  
  <p>What I want to do is read the numbers up to ';', store them in array, execute a method on that array, and then clear the array and start reading from the semicolon again. Here you can see the execution of the program with the input seen above:</p>
  
  <p>read [1,2,3,4,5,6,7,8,9] -> Execute method X -> [] Clear array -> [10 11 12] -> execute method X...</p>
  
  <p>I think a variation of the following code would do the trick, but I don't know enough ruby to do this myself. </p>
  
  <pre><code> a = []
   File.open('names.txt') do |f|
     f.each_line do |line|
       a &lt;&lt; line.split.map(&amp;:to_i)
     end
   end
  </code></pre>
  
  <p>Thanks for your help! This is for curiosity, not an assignment or anything else. I'm trying to build ruby skills by doing simple things. </p>