in reply to
Re: Still problems with recursive coding.
in thread Still problems with recursive coding.
Well, with respect to maintainability, I would think that File::Find would be much easier to maintain, once you understand how it works.
As for your code, the problem is the line
my @files = readdir(DIR) || die "Unable to read $workdir: $!\n";
operator has a higher precedence than the assignment, which means the readdir()
gets evaluated in a scalar context; i.e., it returns only one directory entry. Try the or
operator, for the effect you're looking for:
my @files = readdir(DIR) or die "Unable to read $workdir: $!\n";
(Now, if you had been using File::Find, you wouldn't have had to figure this out ;-)