#!/usr/bin/perl -w use strict; use File::Find; my @qualifiers = (); my $today = time; my $ten_days = ( 60 # seconds in a minute * 60 # minutes in an hour * 24 # hours in a day * 10 ); # the number of days sub process_file { push @qualifiers, $File::Find::name if is_ten_days_old(); } sub is_ten_days_old { # File::Find has done the following for you: # - chdir to the directory where this file resides # - set $_ to the basename of the file # - set $File::Find::name to the fully-qualified name of the file # Don't check ages on directories. return 0 if -d; # stats $_; ninth item is modification date my $age = (stat(_))[9]; # returns true if old enough, false if not return $today - $age > $ten_days; } find(\&process_file, @ARGV); # Print all the files qualifying: foreach (@qualifiers) { print $_,"\n"; } #### C:> perld tendays.pl C:\this\directory\please