my $total = 0; opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened."); while ($_ = readdir DIR){$total++ if -f and /\d/o } closedir DIR;