J
Jay Sun Ex
I am working on a recursive program that prints out all directories
and files recursively starting from whatever directory is passed to
ARGV[0]. This version of my program is meant for use on windows 2000.
The problem is my program does not capture directories using the if
(-d $blah... file test. Below is my code. Any and all help would be
greatly appreciated.
$root = $ARGV[0];
&recurse($root);
sub recurse {
opendir DIR, $_[0];
foreach $file (readdir DIR) {
if (($file eq ".") or ($file eq "..")) {
#Do nothing
} elsif (-d $file) {
print "\n$file";
$folder_path = $_[0] . "\\" . $file;
push @directories, $folder_path;
} else {
print "\n$file is not a directory";
}
}
close DIR;
foreach $newpath (@directories) {
shift @directories;
&recurse($newpath);
}
}
and files recursively starting from whatever directory is passed to
ARGV[0]. This version of my program is meant for use on windows 2000.
The problem is my program does not capture directories using the if
(-d $blah... file test. Below is my code. Any and all help would be
greatly appreciated.
$root = $ARGV[0];
&recurse($root);
sub recurse {
opendir DIR, $_[0];
foreach $file (readdir DIR) {
if (($file eq ".") or ($file eq "..")) {
#Do nothing
} elsif (-d $file) {
print "\n$file";
$folder_path = $_[0] . "\\" . $file;
push @directories, $folder_path;
} else {
print "\n$file is not a directory";
}
}
close DIR;
foreach $newpath (@directories) {
shift @directories;
&recurse($newpath);
}
}