Title: RE: unlink doesn't

Try changing:

unlink  $file;

to

unlink "$logdir\\$file";  


HTH :)

-----Original Message-----
From: Robert Shields [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 29, 2003 9:34 AM
To: [EMAIL PROTECTED]
Subject: unlink doesn't


my $logdir = $Server->Mappath ("logs");

if (!opendir (LOGDIR, "$logdir")) {

        $Response->write ("Could not open directory $logdir: $!<br/>");

} else {

        my @files = grep (/.*\.xml/, readdir(LOGDIR));

        @files = sort @files;
        @files = sort {$b cmp $a} @files;

        my $nCount = 0;
        foreach my $file (@files) {
       
                if ($nCount < 20)
                {
                        #do some stuff...

                } elsif ($nCount >= 90) {
               
                        #delete if more than 90 logs
                       
                        $Response->write("unlinking file $file<br/>");

                        unlink $file;
                }
                ++$nCount;
}       }      



The output is:

unlinking file 2000_2_1.xml
unlinking file 2000_1_9.xml
unlinking file 2000_1_8.xml
unlinking file 2000_1_7.xml
unlinking file 2000_1_6.xml
unlinking file 2000_1_5.xml
unlinking file 2000_1_4.xml
unlinking file 2000_1_30.xml
unlinking file 2000_1_3.xml
unlinking file 2000_1_29.xml
unlinking file 2000_1_28.xml
unlinking file 2000_1_27.xml
unlinking file 2000_1_26.xml
unlinking file 2000_1_25.xml
unlinking file 2000_1_24.xml

etc.

But the files are still there!

What am I doing wrong?



Rob Shields
Software Engineer
Star Internet Ltd
 
e - [EMAIL PROTECTED]
t - 01285 880085
w - http://www.star.net.uk

This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
_____________________________________________________________________

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to