From: Johnathan Smith Date: 2007-12-06T00:26:14+09:00 Subject: Re: hash > Why do you repost the same question when you got answers already? Are > those answers not propagated to ruby-forum? hi i wasnt sure i had recieved the answers i was looking for. I was provided with a few different bits of code which im very grateful for but I was unable to get working. one of the solutions provided by the previous threat i will post below. Im not provided with any output at all. I was to maintain the tag count as well as creating the hash. if you could point out my errors id be extremly grateful thanks # require 'getoptlong' opts = GetoptLong.new( ['--style', '-n', GetoptLong::NO_ARGUMENT ], ['--database', '-i', GetoptLong::REQUIRED_ARGUMENT] ) $linecount = 0 opts.each do |opt, arg| case opt when '--style' require arg when '--database' end end # # # # process options # # # File.open('reference.txt').each do |line| if line =~ /^tag:/i $linecount += 1 end end puts $linecount 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/.