hi

im writing a class which so far:

- reads a text file
- and prints out the the number of Tags it encounters

however now i want to create an empty hash every time it encounters a
tag
line, and if it encounters any other field, put the field and the
related
value in the hash, using the field name as the key

im unsure of how to go about this
any help or pseudo code would be greatly appreciated
my code is provided below

thanks

.txt file

Tag: ref1
Type: Book
Author: Little, S R

Tag: ref2
Type: Journal
Author: Smith, J

Tag: ref3
Type: Conference Paper
Author: Williams, M

ruby file:

#
#
  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
-- 
Posted via http://www.ruby-forum.com/.