http://www.perlmonks.org?node_id=248343

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a directory tree that is being provided in the form of a flat text file.

/root/dir1/file1
/root/dir1/file2
/root/dir1/file3
/root/dir2/file1


What I would like to do is create a hash out of this information. (note: this file could be of any length and have a variable directory depth)
hash{root}{dir1}{file1} = $value (where $value is determined at run time)

My initial thought was to split each line into an array, and then use the information in node_id=196317 to turn the array into the hash. But this seems less than optimal.

What would be the best way to handle this problem?