#!/usr/bin/perl use warnings; use strict; my @files; my $downloadpath = "/home/content/c/r/e/creatingzion/html/downloads"; my $timestamp = time(); my $modified_time; #[9] in the list of file attributes. my $age_of_file; my $time_to_live = 3600; #return a list of all the mp3 files in the downloadpath opendir(DIR, $downloadpath); @files = grep(/\.mp3$/,readdir(DIR)); closedir(DIR); #end comment #compare each file's last modified time with the current time and delete any files older than the time to live in seconds. foreach $files (@files) { $modified_time = (stat($downloadpath."/".$files))[9]; print $modified_time; $age_of_file = $timestamp - $modified_time; if($age_of_file >= $time_to_live) {unlink($downloadpath."/".$files);} } #end comment