#!/usr/bin/perl opendir(DIR, "/home/archive/logs/old"); @FileList = readdir(DIR); closedir DIR; $current_epoch = timelocal ((localtime)[0,1,2,3,4,5]); foreach $file (@FileList) { $file .= "/home/archive/logs/old" . $file; $file_epoch = (stat($file))[9]; if (($current_epoch - $file_epoch) > "604800") { unlink("$file); } }