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( $_ )); } }