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.