http://qs321.pair.com?node_id=918210


in reply to converting a text into a hash datastructure

See Building an arbitrary-depth, multi-level hash for inspiration, for example this reply pretty much does what you want.