- my $d = DirHandle->new($root)
- or print(STDERR "Can't read $pwd/$root: $!");
- @files = $d->read;
- $d->close;
- @files = grep $_!~/^\.{1,2}$/, @files;
- $bpc->RmTreeQuiet("$pwd/$root", \@files);
- chdir($pwd);
- rmdir($root) || rmdir($root);
+ my $d = DirHandle->new($root);
+ if ( !defined($d) ) {
+ print(STDERR "Can't read $pwd/$root: $!\n");
+ } else {
+ @files = $d->read;
+ $d->close;
+ @files = grep $_!~/^\.{1,2}$/, @files;
+ $bpc->RmTreeQuiet("$pwd/$root", \@files);
+ chdir($pwd);
+ rmdir($root) || rmdir($root);
+ }