i made a small script to clean out logfiles in a dir, actually its a sub in a bigger 
script, but i get some toubles. Be carefull if you run this script, cause it will 
delete files. It runs ok on files, but not on directorys, my guess is that its because 
i am on a win32 system? Also it looks like it translates  the structure as:

d:\temp\huh/CME2_Course/EDU010_ClearCase/EDU010_Products_001.vbs/c

where d:\temp\huh is base dir. That value actually comes from the command line from 
Get::Opt. It doesnt work by doing d:/temp/huh either.  I really dont want to do a 
system call, any ideas what is wrong?

thanks 

//Dave

use strict;
use File::Find qw(finddepth);
my $logdir = "d:\\temp\\huh";
my $age = 5;

#this starts the sub
finddepth (\&del_files, $logdir);

sub del_files{
if (!defined($age)){$age = 7}  #$age comes from another variable, if its not defined 
set it to 7
if (-M >$age && -f){
            print "Deleting $_ its ",-M $_," old\n";
            unlink ($File::Find::name) or warn "couldnt delete  file: 
$File::Find::name\n";
        }
        else
        {
            if (-M >$age && -d)
            {
            print "rmdir $_\n";
            rmdir ($File::Find::name) or warn "couldnt delete directory 
$File::Find::name\n";
            }
        }
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to