Johnathan Smith wrote:

>   File.open('reference.txt').each do |line|
>     if line =~ /^tag:/i
>       $linecount += 1
>     end
>   end
>     puts $linecount
> #

try something like this:

linecount = 0
results =  []
hash = {}
File.open('reference.txt').each do |line|
  m = line.match /^(\w+):\s*([\w+,\s]+)$/
  unless m
    results << hash unless hash.empty?
    hash = {}
  else
    linecount += 1
    hash[m[1]] = m[2].chomp
  end
end
-- 
Posted via http://www.ruby-forum.com/.