... and you should be testing the return value of unlink since it can fail :-)
Something like this should work (untested code):
@keep{@files} = (1) x @files; foreach my $file ( @filelist ) { next unless $keep{$file}; unlink $file == 1 or warn "could not unlink $file ($!)\n"; }
(yes, I know that you could just test unlink for truth/false in this instance - but I always like to remind myself that it returns the number of successful deletions rather than success/failure).
In reply to Re^4: File deletion
by adrianh
in thread File deletion
by cored
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |