in reply to del files that is 7 days or older

Assuming you don't have a huge list of files to delete, this should be a reasonable approach. A couple of things...avoid system and backtick calls if you can do it easily within.
#!/usr/bin/perl -w use strict; my $del_dir = "/directory/location/of/files"; my $del_days = 7; #delete files that are X days old my $now = time(); my $del_date = $now - (86400 * $del_days); #current date - (second per + day * days) my @dir_list; chdir $del_dir; opendir(DH, $del_dir) or die "Unable to read $del_dir directory. ERRO +R: $!\n"; @dir_list = grep { /(txt)$/ } readdir(DH); #build list of files that m +atch "txt" extension closedir(DH); foreach (@dir_list) { my ($file_time) = (stat($_)) [9]; # unlink $_ if ($del_date > $file_time); print "If the above was not commented out, $_ would have been dele +ted!\n"; }
-THRAK