use File::DosGlob 'glob'; my @dir_regex = glob "//share16/ABC/*/Output/"; for my $dir (@dir_regex) { find({ wanted => \&process_file, no_chdir => 1 }, $dir) or die $!; } sub process_file { my $dummy = $_; if (-f $dummy) { my $filename = "//share16/TOOLS/report.txt"; open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!"; my $last_mod_time = ctime(stat($dummy)->mtime); print $fh "$last_mod_time $dummy\n"; } close $fh; }