my $path = "."; &scan_files($path); print "\n"; exit(0); sub scan_files { my (@scandirs,$scandir,@files,$file,$list); $scandir = $_[0]; opendir(DIR,$scandir) || warn "can't open the directory $scandir: $!\n"; @scandirs = grep {!(/^\./) && -d "$scandir/$_"} readdir(DIR); rewinddir(DIR); @files=grep {!(/^\./) && -f "$scandir/$_" && (/\.log$/)} readdir(DIR); closedir (DIR); for $list(0..$#scandirs){ &scan_files($scandir."/".$scandirs[$list]); } if ($#files > 0){ foreach $file(@files){ print "$file\n"; } } return 1; }