use File::Find; my @time = localtime(); $time[5] += 1900; $time[4]++; my $curmonth = $time[4]; my $today = $time[3]; my $three = $curmonth - 0; my $year = $time[5]; my @filearray; my ($dirname, $outputfile) = <@ARGV>; chomp($dirname); chomp($outputfile); print "Beginning... "; my $filecounter = 0; open OUTPUT, ">$outputfile"; print "\nFrom the Directory: ", $dirname; print OUTPUT "\nFrom the Directory: ", $dirname, "\n"; opendir DIR, $dirname; chdir($dirname); my @directories = readdir (DIR); find(\&wanted, @directories); sub wanted { -l && !-e && print "bad link: $File::Find::name\n"; my $filepass = $File::Find::name; my $sendcheck = $File::Find::name; if ($filepass eq ".."){ print "\n\n\tFrom $dirname -- Files/Directories Scanned: ",$filecounter, "\n"; close OUTPUT; exit;}else{ &CheckMods($sendcheck); } } sub CheckMods { my $file = shift; my $tempvar = $_; my @info = stat($tempvar); my $last_access = $info[8]; my $last_modification = $info[9]; $filecounter++; if (@info){ my @times = (localtime($last_modification)); $times[4]++; $times[5] += 1900; $notify =(" Date: "."$times[4]/$times[3]/$times[5]"); print "Checking folder... "; if ($times[5] < $year){ push(@filearray, $_); &delete(); }else{ if ($year = $times[5]){ if ($three > $times[4]){ push(@filearray,$file); &delete(); } } } } else { print OUTPUT "\n"; } return; } sub delete{ foreach (@filearray){ print OUTPUT "Deleting the following file: $_\n"; print "Deleting the following file: $_\n"; unlink || warn "Can not delete file $_: $!\n"; }return; } close OUTPUT;