make an array of a directory tree/files paths in perl
Posted on 2009-04-05
I am looking (without installing extra packages) to get an array to have a directory structure of a bunch of folders then go through each folder and list the files, (and also know the directory its in)
Take the following file paths (starting from 'My Photos' for instance):
I would like to find the code that makes me an array of the directorys (recursively) in a given path - in the above example I would like @dirs = ("/home/tim/my photos/journey/" , "/home/tim/my photos/birthday/")
Then I want to get the full file paths into another array... so @files = ("/home/tim/my photos/journey/1.jpg","/home/tim/my photos/journey/2.jpg", "/home/tim/my photos/journey/3.jpg"....
I know this should be easy but I can't find a straightforward approach, I don't wish to have it rely on other packages as it has to run from different web servers which won't let me install extra packages from CPAN etc.