use warnings; use strict; use File::Glob ':bsd_glob'; my $DIR = "C:/Users/tyang/Documents/Traning"; my @files = glob("$DIR/*.txt"); for my $file (@files) { next unless -f $file; print $file, ' '; my $age = -M $file; if ($age > 7) { print "the age is ",int($age)," old than a week"; } print "\n"; }