Split string into a hash of hashes (perl)
问题 at the moment im a little confused.. I am looking for a way to write a string with an indefinite number of words (separated by a slash) in a recursive hash. These "strings" are output from a text database. Given is for example "office/1/hardware/mouse/count/200" the next one can be longer or shorter.. This must be created from it: { office { 1{ hardware { mouse { count => 200 } } } } } Any idea ? 回答1: Work backwards. Split the string. Use the last two elements to make the inner-most hash.