Jewel,
I use something similar to what you're requesting to remove files that are more than 15 days old. following is the script I use. It's fairly commented so I know what I was thinking when I wrote it.
Some of the guru's here at tek-tips helped me write it so it's only right that I should share.
I haven't attempted to make any changes for you're app. but I'm sure you can get it to work for you.
#======================================================
#!/usr/bin/perl -w
$^T = time; # the Time when the script starts running
# because stat() and -M uses this to compare age
# of the file from now
$dir = "o:\\data\\dpboxes\\store";
opendir (DIR, $dir) || die "Shucks $!";
@files = readdir (DIR);
closedir (DIR);
open (Store, ">>e:\\perl\\code\\rts-store.txt"

|| die "Shucks $!";
foreach $file (@files)
{
next if($file =~ /^\./); # skip if it's the '.' or '..' directories
@data = stat("$dir\\$file"

; # get info from file - like timestamp
next unless -M ("$dir\\$file"

> 15; # only get files that are more than
# 15 days old
# the $dir makes sure it's looking
# in the correct directory
$write_secs = $data[9]; # the [9] gets $mtime from stat()
$write_secs += 1900; # add 1900 to get into year 2000 +
print "\n$file - ", scalar localtime($write_secs);
# print the file name and the timestamp
print Store "\n$file - ", scalar localtime($write_secs);
unlink "$dir\\$file"; # delete the file
$cnt++; # keep track of how many were done
}
close (Store);
print "\n$cnt";
#===============================================================================
Hope this helps!
tgus
____________________________________________________
A father's calling is eternal, and its importance transcends time.