Karger78 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I have been trying to figure out how to do this. I have a network path e.g \\karger78\testing So that is coded into a variable called $hardPath; Now I do a directory scan of and bilding a list of files and directory into an array by using the following: my @FullList = File::Find::Rule->file()->in($hardPath); Now what I would like to do is just split all the sub directories of $hardPath into an array. Any ideas?

Replies are listed 'Best First'.
Re: Splitting file path
by toolic (Bishop) on Feb 10, 2010 at 20:08 UTC
    From the SYNOPSIS of File::Find::Rule
    use File::Find::Rule; # find all the subdirectories of a given directory my @subdirs = File::Find::Rule->directory->in($hardPath);
Re: Splitting file path
by ikegami (Patriarch) on Feb 10, 2010 at 20:32 UTC
    What does "splitting subdirectories" mean?
      well any sub directorys underneeth I want split up into each element in the array.
        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

        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 = ( ???, ???, ???, ???, ???, ???, );