What am I missing? I want to remove all the files on a volume that are older than 30 days. The first step is to find them. In sh I say:
find /backup -mtime +30
In perl I say:
#!/usr/bin/perl -w
use strict;
my $dir = $ARGV[0];
my $thirty_days_ago = time() - ( 30 * 24 * 60 * 60 * 60 );
my @files;
use File::Find;
find( \&wanted, $dir );
sub wanted {
my @stats = ();
# ignore symlinks
if ( !-l $_ ) {
@stats = stat($_) or warn "couldn't stat $_\n";
}
# 9 is mtime;
if ( !-l $_ && $stats[9] < $thirty_days_ago ) {
push @files, "${File::Find::dir}/$_";
}
}
print join ( "\n", @files ), "\n";
email: mandog