First off, I gather that a bunch of the stuff at the top of this latest version of yours is not relevant to the problem: your "%directories" hash, the "get_rootdir" sub and the $root(link|user|name variables are all no-ops. You are just using File::Find on whatever the current working directory happens to be.
So, putting all that extra stuff aside, the only change I think you need in the operative code is this:
I think the point here is: once you get into the first subdirectory, removing just the "$rootdir" string leaves $_ with the path separator character at the start. That somehow causes fileparse() to not play nice with the recursive "load_tree" function. Anyway, try that out and see if it helps.sub wanted { local $_ = $File::Find::name; if ( -f ) { # only work on data files (skip directories) s{\Q$rootdir\E[\\/]}{}; # remove the rootdir string from the path +name # ... ALONG WITH THE SUBSEQUENT "\" OR "/" + CHARACTER load_tree( $tree{$rootdir}, fileparse( $_ )); } }
In reply to Re^7: Directory Tree Structure
by graff
in thread Directory Tree Structure
by rupesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |