That's fairly easy. Just see perldoc -f stat. You can get all possible data about a file, including the last change timestamp.
Please note, you cannot usually get the creation time, because it is not recorded by all file/operating systems.
sub wanted {
return unless /\.out$/;
my $ctime = (stat $_)[9];
if ($ctime < time()-(2*60*60)) {
print "$_ is older than 2 hours.\n";
} elsif ($ctime > time()) {
print "$_ has used a time machine to get here!\n";
} else {
un#link $_;
print "I hate new files.\n";
}
}
|