On Dec 4, 9:42 am, Johnathan Smith <stu... / hotmail.com> wrote:
> what i want to do is 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 (e.g Type and Author) as the key
>
> im not sure if any of the help you provived achieves this but any help
> on this matter would be greatly appreciated

Unless I'm misunderstanding you, both of the solutions I provided do
what you are describing.

You can even see this logic explicitly here, in the first solution:
   if key == "Tag"
    last_tag = data
    info[ data ] = {}
  else
    info[ last_tag ][ key ] = data
  end


Does the output not look like what you expect?

  pp info
  #=> {"ref4 "=>{"Author"=>"Jones, M B", "Type"=>"Book "},
  #=>  "ref3 "=>{"Author"=>"Williams, M ", "Type"=>"Conference Paper
"},
  #=>  "ref2 "=>{"Author"=>"Smith, J ", "Type"=>"Journal "},
  #=>  "ref1 "=>{"Author"=>"Little, S R ", "Type"=>"Book "}}

If not, what actual output did you want?