in reply to Re^6: Directory Tree Structure
in thread Directory Tree Structure
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( $_ )); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Directory Tree Structure
by Lady_Aleena (Priest) on Nov 05, 2009 at 06:03 UTC | |
by graff (Chancellor) on Nov 05, 2009 at 06:58 UTC | |
by Lady_Aleena (Priest) on Nov 05, 2009 at 19:59 UTC | |
by graff (Chancellor) on Nov 05, 2009 at 22:59 UTC |