heigold1 has asked for the wisdom of the Perl Monks concerning the following question:
sub ScanDirectory{ my ($startdir) = @_; chdir("$stardir\\") or die "Unable to enter dir $startdir:$!\n"; opendir(DIR, "$startdir") or die "Unable to open $workdir:$!\n"; my @names = readdir(DIR) or die "Unable to read $workdir:$!\n"; closedir(DIR); foreach my $name (@names) { next if ($name eq "."); next if ($name eq ".."); if (-d $name) # is this a directory? { print "DIRECTORY $currentDir \n"; } else { print "FILE $currentFile"; # it always passes through this condition. } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The -d switch isn't working as I expected it to (test to see if its a directory)
by Fletch (Bishop) on Jan 07, 2005 at 19:08 UTC | |
|
Re: The -d switch isn't working as I expected it to (test to see if its a directory)
by bluto (Curate) on Jan 07, 2005 at 20:29 UTC | |
by sgifford (Prior) on Jan 07, 2005 at 21:40 UTC | |
by bluto (Curate) on Jan 07, 2005 at 23:08 UTC | |
by sgifford (Prior) on Jan 07, 2005 at 23:55 UTC | |
by bluto (Curate) on Jan 10, 2005 at 16:37 UTC | |
|
Re: The -d switch isn't working as I expected it to (test to see if its a directory)
by amw1 (Friar) on Jan 07, 2005 at 19:27 UTC |