This does not work! It's as if the statement is ignored, I still continue to try to process the sub-directories. The files are in a directory off of the root like c:\myfiles. There are subdirectories in this directory that are being picked up as if they are files. I need to skip the subdirectories. -d does not work! | [reply] |
Did you turn the result of readdir (which is just the name within the selected directory) into a path by reattaching the directory name in front? If not, you're gonna get an odd response.
| [reply] |
Thank you, Thank you, Thank you. By referencing the full file path within the condition test, instead of just the name of the file, this works. I was mistakenly under the impression that by being positioned in that directory, on the direcory read, perl would resolve the file as to being a sub-directory or a file. But your method worked fine. Thanks again.
| [reply] |
#!perl -w
use strict;
opendir (DIR, './') || die "can't open dir:: $! \n";
for my $file(readdir(DIR)) {
next if -d $file;
print $file."\n";
}
| [reply] [d/l] |
Thanks, but the response by Merlyn did the trick.
| [reply] |