To a folder -
sub process_dir{ my $dir = shift; if ($dir !~ /sections$/i) { if (opendir(DIR, $dir)) { my @entries = grep { !/^\.+/ } readdir(DIR); closedir(DIR); #close the directory foreach my $e (@entries) { next if (! -d "$dir/$e"); process_dir("$dir/$e"); } } else { $logger->logwarn("[opendir] $dir ($!)"); } } else { my @files; if (opendir(DIR, $dir)) {@files = grep { ! -d "$dir/$_" } readdir(DIR); closedir(DIR); } foreach my $f (@files) { next if -d "$dir/$f"; #$logger->logwarn("File is $dir/$f"); (my $subdir = $dir) =~ s|^.*/data/||; (my $manurl = "/manuals/$subdir/$f") =~ s/(?:\..*|$)/.shtml/; if (open(IN, '<:utf8', "$dir/$f")) { my $xml = do { local $/; }; close(IN); my $rootnode = TeamSite::XMLnode->new($xml); (my $type = lc($rootnode->value('info.type'))) =~ s|\s+||gsm; my $revdate = get_rev_date("$dir/$f"); my $mantitle = $rootnode->value('info.title'); (my $char = $mantitle) =~ s|^(.).*|\U$1\E|; my $hash = { url => $manurl, title => $mantitle, revdate => $revdate, }; push(@{$TOC{$type}{$char}}, $hash); } else { $logger->logwarn(" $dir/$f ($!)"); } } }}
This code was originally mine - how much it was changed since I wrote it (3 or 4 years ago?) I don't know.I do see two error in the code - which I highlight below - try making those changes and see if it fixes the problem: next if -d "$dir/$f";Hope that helps.
next if -d "$dir/$f";
I pointed out that change but she needs to traverse the sub dir, not skip it.
Actually - that line should be omitted completely based on the fix to the grep line above it - there should not be any directories within @files.If I recall - and it's been a while now - there was a conscious decision made not to parse DCRs within sub-directories of the sections directory .. at least that's how the code appears to have been written and I seem to recall it was all working when I was last there.If the design has changed, then the code needs to be re-thought all the way through, and could potentially be re-implemented in a simpler manner.
Maybe, it certainly is skipping the subdirs. But she wants them processed.
Cindy - is the issue that you want to process sub-directories (that weren't processed before) - or that you want to get rid of the errors you are seeing (which started happening some time recently?) ?
read post #9
That skips the section directory also -I am trying to read the files in the sub-directory Sections i.e.Sections/*.shtmlI am trying to skip the sub-directories inside of Sections i.e.Sections/letters/*.shtmlIs this possible?
Sorry I have been on vacation.What has changed since you were here is that there have been directory's placed inside of the sections directory i.e. sections/letters. The perl script below reads the sections directory and creates a TOC. We wanted the directorys to be skipped because the workflow is taking about 2 minutes to run and we thought that walking through the directories and getting permissions denied was part of the reason it is taking so long so we wanted to skip those directories.Do you think if I make the changes you suggest it will speed up the processing time?[...]Hope that helps.