in reply to Re: Problem unlinking files
in thread Problem unlinking files
Just to add to the information. What i want actaually is a refreshing of the directory while its undergoing the 'readdir while loop', if some deletion of files happens in this while loop.
Why do you want to "refresh" the directory (and what do you mean by that, anyway)? It would have been better if you had added a sample of the code you have tried.
Maybe rather than deleting files within the loop, you might want to just build a list of files to be deleted (store the file names as keys in a hash), and then delete them as a separate step:
opendir(DIR,$somepath); my %todelete; while( $file = grep /[^.]/, readdir DIR ) { if ( !exists( $todelete{$file} ) and some_test( "$somepath/$file" +)) { $todelete{$file} = undef; ( my $otherfile = $file ) =~ s/this/that/; $todelete{$otherfile} = undef; } } unlink "$somepath/$_" for ( keys %todelete );
|
|---|