As you know, "there's more than one way to do it...", but this may help get you started:
#!/usr/bin/perl
use strict;
use File::Find;
if ($ARGV[0] eq "") { $ARGV[0]="."; }
my @file_list;
find ( sub {
my $file = $File::Find::name;
if ( -f $file && $file =~ /^DATE_/) {
push (@file_list, $file)
}
}, @ARGV);
my $now = time(); # get current time
my $AGE = 60*60*24*14; # convert 14 days into seconds
for my $file (@file_list) {
my @stats = stat($file);
if ($now-$stats[9] > $AGE) { # file older than 14 days
print "$file\n";
}
}
Assuming you name this script cleanup.pl, you would use it like this:
cleanup.pl /var/backups/repository
If you don't specify a directory, it will use whatever the current directory is.
Note than the stats function returns an array of info, which I'm saving into the @stats array. Element 9 contains the last modification time, which may be different than the actual creation time (read up on stats so you know which one you want to use).
Also, this example just prints out the files starting with DATE_ that are 14 days old (or older). Change the print statement to:
unlink $file;
to actually delete them. This may leave you with empty directories, but you can write another script to delete empty directories after running this one.