So essentially what I’m trying to do is go through a directory and perform an action on all of the files, in this case, the sub searchForErrors. This sub works. What I have so far is:
sub proccessFiles{
my $path = $ARGV[2];
opendir(DIR, $path) or die "Unable to open $path: $!";
my @files = readdir(DIR);
@files = map{$path . '/' . $_ } @files;
closedir(DIR);
for (@files){
if(-d $_){
process_files($_);
}
else{
searchForErrors;
}
}
}
proccessFiles($path);
Any help/suggestions would be great. And again, I’m new to Perl, so the more explanation the better. Thank you!
You should use the
File::Findmodule instead of trying to reinvent the wheel:A problem with your current code is that you are including
.and..directories in your recursive search, which will no doubt causedeep recursionerrors.