Norman Zhang wrote:
> 
> Hi,

Hello,

> I've /share_folder with many user folders.
> 
> e.g.,
> 
> /share_folder/user_a
> /share_folder/user_b
> ...
> 
> I would like to scan all user folders for files that are older than 30
> days and delete them. Is this doable with Perl?

Something like this (untested):

#!/usr/bin/perl
use warnings;
use strict;
use File::Find;

my $folder = '/share_folder';

my @files;
find( sub { -f and -M _ > 30 and push @files, $File::Find::name }, $folder );

for my $file ( @files ) {
    unlink $file or warn "Cannot delete file $file: $!";
    }

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to