ChrisNutting has asked for the wisdom of the Perl Monks concerning the following question:
I also tried this:sub hasSubs { my $dir = shift; my $hasSubs=0; if (!($dir eq "\\")) { $dir="$dir\\"; } opendir (CURRENT, $dir) || die("Cannot open the dir: $dir"); foreach my $file (readdir(CURRENT)) { next if (($file eq ".") || ($file eq "..")); if (-d $dir.$file) { $hasSubs = 1; last; } } closedir CURRENT; return $hasSubs; }
Which worked better on some dirs, but slower on others :(my @subDirList=`dir /ad /b \"$dir\"`; if ($#subDirList >= 0) { $hasSubs=1; } for (my $counter = 0; $counter <= $#subDirList; $counter++) { chomp $subDirList[$counter]; $hasSubs = 1; }
("`-''-/").___..--''"`-._
`6_ 6 ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_..' ,'
(il),-'' (li),' ((!.-'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Testing for existance of subdirectories
by tadman (Prior) on Aug 19, 2001 at 12:31 UTC | |
by ChrisNutting (Initiate) on Aug 19, 2001 at 14:34 UTC | |
by mugwumpjism (Hermit) on Aug 19, 2001 at 14:56 UTC | |
by ChrisNutting (Initiate) on Aug 19, 2001 at 15:06 UTC | |
|
Re: Testing for existance of subdirectories
by mugwumpjism (Hermit) on Aug 19, 2001 at 12:27 UTC |