Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
However if the contents of $searchpath/* is itself a set of sub-directories I wish to print the contents of those as well (displaying the full path for each directory, but not the files within it) down the tree until no more sub-directories exist. I don't won't know the level of recursivness until the code is run.my $searchpath="/usr/storage"; print "Here are the contents of the chosen search path\n"; sle +ep 2; my @files = <$searchpath/*>; foreach my $file (@files) { print $file . "\n"; }
e.g.
Any help appreciated ./usr/storage (top level directory) location1 (this is a directory) location2 (this is a directory) afile1 (this is a file) afile2 /usr/storage/location1 afile2 afile3 location3 (this is a directory) /usr/storage/location2 afile /usr/storage/location1/location3 afile afile1 afile2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recursive directory listing
by dHarry (Abbot) on Sep 17, 2010 at 10:09 UTC | |
|
Re: Recursive directory listing
by zentara (Cardinal) on Sep 17, 2010 at 10:23 UTC | |
|
Re: Recursive directory listing
by Khen1950fx (Canon) on Sep 17, 2010 at 11:13 UTC | |
by Anonymous Monk on Sep 17, 2010 at 11:47 UTC | |
|
Re: Recursive directory listing
by Generoso (Prior) on Sep 17, 2010 at 14:52 UTC |