Hello all,

I am trying empty a directory with over 4000 files with a script, and do not understand why I can only delete half at a time. I am guessing that the directory handle has a size limitation?? Is there a way to load the contents into a large array or am I going about this all wrong? Please forgive the newbie question. I'm trying to hack this with my copy of the Perl Bookshelf and limited practical experience.

#!/usr/bin/perl
#open directory and load contents into hash
$dir = "/test/directory";
opendir(@DIR, $dir) or die "cant opendir $dir: $!";
while (defined($file = readdir(DIR))) {
if ($file =~ "klee") { #matching a specific file, avoiding . & .. and .AppleDouble directory
$file2 = $dir . "/" . $file;
unlink($file2);
print "unlinking $file2...\n";
}
}
closedir(@DIR);



Thanks! -- Charles F. Harvey [EMAIL PROTECTED] Manager, Help Desk Services Design | Media Arts, UCLA http://support.design.ucla.edu


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to