http://www.perlmonks.org?node_id=35802

curtisb has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone tell me what is wrong with this. I have been working on this and it works like 1 out of 100 times. Do I need to use WIN32 or something. This is going to be ran on a Win NT Server in the future. The directories in the code are only test directories.
#!/usr/bin/perl -w $dir = "c:/mydocu~1/Netscape/Suitespot"; print "Starting Delete Process\n"; print "\n"; opendir(DIR, "$dir") || die "No $dir: $!"; @files = grep(!/^\./, readdir(DIR)); @files = sort @files; foreach(@files) { print "$_\n"; next if ($_ !~ /^\.log$/i); next if ($_ !~ /^\.\d+\w+\-\d+\wm$/i); next if ($_ !~ /^\.txt$/i); unlink "$dir/$_" || print "Unable to delete $_: $!"; } print "\n"; print "Deleted all requested files.\n"; closedir(DIR);
Thanks