-- vek --opendir (THEDIR, $theDir) || die "Could not read $theDir - $!\n"; my ($filesFound, $dirsFound); for my $fileFound (readdir(THEDIR)) { next if ($fileFound eq '.' || $fileFound eq '..'); if (-d $fileFound) { # we found a directory... $dirsFound++; } else { # looks like it's a file... $filesFound++; } } if ($filesFound) { print "Found $filesFound files in $theDir.\n"; } else { print "No files were found in $theDir.\n"; } if ($dirsFound) { print "Found $dirsFound directories in $theDir.\n"; } else { print "No directories were found in $theDir.\n"; }
In reply to Re: A couple of ?'s
by vek
in thread Finding files and subdirectories in a directory (was: A couple of ?'s)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |