I know this sounds odd but it's got me really stuck. I have the following code in a subroutine called remove_CVS_copies. It's meant to progress recursively down a directory structure and delete all the directories it finds called "CVS."
But it does not seem to be detecting directories correctly.
I get the message "it thinks CVS is a file" a lot and I never get the message "# recurse down into the directory $file".
Can anyone please offer any advice?
--------------------------------------
My doctor says that I have a malformed public-duty gland and that I am therefore excused from saving universes.
But it does not seem to be detecting directories correctly.
Code:
opendir(DIR, $start) or die "can't opendir for $start: $!\n";
while (defined($file = readdir(DIR)))
{
# check all directories
if( -d $file ){
if( $file eq "CVS" ){
rmtree($start ."/".$file) or die "unable to rmtree $start/$file: $!\n";
}
elsif($file ne "." && $file ne ".."){
print "# recurse down into the directory $file\n";
remove_CVS_copies($start ."/". $file);
}
}
elsif( $file eq "CVS" ){
print "it thinks CVS is a file!\n";
rmtree($start ."/". $file) or die "unable to rmtree $start/$file: $!\n";
}
}
closedir(DIR);
Can anyone please offer any advice?
--------------------------------------
My doctor says that I have a malformed public-duty gland and that I am therefore excused from saving universes.