in reply to using $ftp->mdtm($file)
I've JUST tonight finished writing a program to do this type of task, although it doesn't connect via FTP, but can scan any visible drive. I designed it to scan our terabyte server at work and remove the compounding temp files on there. On its maiden voyage it remoeved some near 12Gb of temp files, about 400,000 files. I'm sure you can amend it to suit your needs.
You can specify any number of files you wanted deleted based on regular expressions in external configuration files. You can also specify entire paths to be removed if you want. It'll test them to make sure they are all older than 7 days. Having these in external files means you can change what you want deleted without having to always be changing the source code.
It'll also output a result of how much space was recovered, files scanned etc. etc.
Its taken me a few months to write as in the process I found that Perl's File::Find module had a memory leak and required me to rewrite the core of the program after I'd completed it the first time. I've also written a Tech Spec for it to give you an overview to the code.
If you want a copy I won't post it here because its some 600 lines long but email me and I'll send you a copy and the tech spec. You may be able to adapt it to your means and make it work with FTP. Or it may just give you some ideas. Considering I started it so long ago I'd probably write it differently now, I'm not overly happy with the code, but it works a treat and I can't be bothered spending any more time on it.
Cheers,
Dean
crabbdean at yahoo.com.au