use strict; my $DIR = "C:/Users/tyang/Documents/Traning"; opendir DIR, $DIR or die "could not open directory: $!"; while (my $file = readdir DIR) { my @files = grep ( -f ,<*.txt>); # Write them out foreach (@files) { print $file, ' '; my $age = -M $file; if ($age > 7) {print "the age is", int($age),"old than a week\n";} } }