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?
/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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: file tree to hash
by dakkar (Hermit) on Apr 05, 2003 at 22:15 UTC | |
Re: file tree to hash
by pg (Canon) on Apr 06, 2003 at 00:09 UTC | |
by merlyn (Sage) on Apr 08, 2003 at 04:43 UTC | |
Re: file tree to hash
by chromatic (Archbishop) on Apr 05, 2003 at 22:09 UTC | |
Re: file tree to hash
by DrManhattan (Chaplain) on Apr 06, 2003 at 02:40 UTC | |
by merlyn (Sage) on Apr 08, 2003 at 04:44 UTC |
Back to
Seekers of Perl Wisdom