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

well any sub directorys underneeth I want split up into each element in the array.

Replies are listed 'Best First'.
Re^3: Splitting file path
by Argel (Prior) on Feb 10, 2010 at 23:49 UTC
    You're still not being very clear -- do you want just the directories one level below $hardPath or all directories below $hardPath? Do you want $hardPath included for each entry in the array or do you just want the part of the path that is below $hardPath? For example, given "$hardPath/foo/bar" do you want "$hardPath/foo" or "$hardPath/foo" and "$hardPath/foo/bar"? And do you want "$hardPath/foo" or just "foo"? That ambiguity is why you have been getting downvotes on your question.

    Elda Taluta; Sarks Sark; Ark Arks

Re^3: Splitting file path
by ikegami (Patriarch) on Feb 11, 2010 at 10:06 UTC
    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 = ( ???, ???, ???, ???, ???, ???, );
      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);