I want to recursively scan all the directories and subdirectories from a given starting point. At some point in the future I'm going to do things to the security on all files in the directory - the reason I'm using Perl is that (a) DOS batch is rubbish and (b) CACLS.EXE is rubbish and (C) I need to look at the security before doing the aforementioned things.
But enough natter; here's the subroutine that, at the moment, is intended to print out a recursive listing of the directory tree:
At the moment, it simply prints out the very first eligible item, lots of times, with the odd warning about deep recursion.sub printdir { my $item; foreach $item(@_) { if (-d $item) { print "$item\n"; opendir(SUBDIR, $item) or croak "Can't open directory :$!"; my @subdir_items = readdir(SUBDIR); #+ closedir(SUBDIR); #+ printdir(@subdir_items); #+ } } }
This nicely printed out the items in a single directory before I added the lines marked with #+.
In reply to Recursive directory scanning by pwhysall
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |