sub make_space { my $folder_name = $_[0]; opendir DIR_HANDLE, ".$folder_name"; my @filelist = readdir DIR_HANDLE; close DIR_HANDLE; foreach $filename(@filelist) { $st = stat($ilename) $actime = st->$atime } #custom sort routine to sort the filelist according to their last accessed date @sorted_list = sort { ($actime{$a}) > ($actime{$b}) } @filelist; #deleting 1st 100 entries in the sorted array for($i =0; $i <=99 ;$i=$i+1) { unlink($sorted_list[i]); } }