sub is_empty_dir { my $path = shift(); my $rv = 1; opendir DIR, $path or die "$path: $!\n"; while (my $entry = readdir(DIR)) { next if ($entry eq "." or $entry eq ".."); # Entry found beneath $path, directory is not empty $rv = 0; last; } closedir(DIR); return $rv; }