See Building an arbitrary-depth, multi-level hash for inspiration, for example this reply pretty much does what you want.
In reply to Re: converting a text into a hash datastructure
by moritz
in thread converting a text into a hash datastructure
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |