in reply to Re^2: Splitting file path
in thread Splitting file path

Using "splitting subdirectories" to explain "splitting subdirectories" is not very useful.

Let's try something different. Give an example directory tree and show us what you want in the array.

dir1\file1 dir2\file2 dir2\file3 dir2\dir3\file4
should give
@array = ( ???, ???, ???, ???, ???, ???, );

Replies are listed 'Best First'.
Re^4: Splitting file path
by Karger78 (Beadle) on Feb 11, 2010 at 16:12 UTC
    ok. Perhaps it was a poor job explaining on my part. so we have a var called $hardPath. E.g \\test So what I would like to do is build an array of any sub directories within $hardPath. E.g $hardPath\foo\bar So then the array would contain foo, and bar. Does that make sense?

      Doesn't the code in Re: Splitting file path do that?

      Well, it sounds like you want just the file name of of the directories, not the whole path. I don't see how this could be useful, but if that's what you want, use File::Basename's basename:

      use File::Find::Rule qw( ); use File::Basename qw( basename ); my @subdirs = map basename($_), File::Find::Rule->directory->in($hardPath);