my $dir = "C:\\Perl"; opendir DH, $dir or die "Cant open $dir: $!"; foreach $file (readdir DH) { print "files in $dir id $file\n"; } closedir DH; my $oldest; my $oldtime = 0; for (glob "$dir/*") { my $thistime = -C; if ($thistime > $oldtime) { ($oldest, $oldtime) = ($_, $thistime); } } printf "The oldest file was %s, and it was %.1f days old.\n", $oldest, $oldtime;