in reply to Deleting files

You can simply provide unlink with a list of filenames as matched by your criteria, which is where File::Find::Rule becomes rather handy
use File::Find::Rule; unlink find(file => mtime => '<='.(time - 5 * 24 * 3600), in => $dir);
See. unlink and File::Find::Rule for more info.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Deleting files
by flyingmoose (Priest) on Feb 02, 2004 at 18:28 UTC
    In attempts to suck-up to merlyn, I used File::Finder for the first practical time today, and it totally kicks butt for things like this. The filter-chaining scheme means you can stack filters very cleanly, and it's legal to stick evals in the filter chain as well. So you can filter based on name, time, arbitrary code, etc, and then execute arbitrary code when you are done. It turns File::Find into a quite elegant one liner.

    Straight from the docs:

    my $blaster = File::Finder->atime("+30")->eval(sub { unlink });
    update: be sure you know the difference between atime, mtime, and ctime, as jacques rightfully points out below. mtime is most likely the right one in most scenarios. Chosing the wrong one will mean important things get deleted!