J
jimnl69
How can I get a list of JUST the first level of directories? Everything
I try either gives me only . and .. or everything.
I've tried:
if ( opendir( DIR, $dir ) ) {
@dirs = grep( -d "$dir", readdir( DIR ) );
closedir( DIR );
@dirs = sort grep( !/^\.\.?$/, @dirs );
}
but I get filenames too.
I've tried:
my @filesAndDirs = $dh->read();
but I get filenames too. When I try to filter them out with a -d, all I
am left with is . and ..
What I want to do is get a list of all directories. Then go into each
one of those and get the list of directories there so I can do some
processing. I don't care about any further down, just the top 2 levels.
I've gone through every post I can find on directories for the last 2
weeks and none of them answer the question successfully on getting just
a list of directories; no filenames and not just . and ..
Any help greatly appreciated!
I try either gives me only . and .. or everything.
I've tried:
if ( opendir( DIR, $dir ) ) {
@dirs = grep( -d "$dir", readdir( DIR ) );
closedir( DIR );
@dirs = sort grep( !/^\.\.?$/, @dirs );
}
but I get filenames too.
I've tried:
my @filesAndDirs = $dh->read();
but I get filenames too. When I try to filter them out with a -d, all I
am left with is . and ..
What I want to do is get a list of all directories. Then go into each
one of those and get the list of directories there so I can do some
processing. I don't care about any further down, just the top 2 levels.
I've gone through every post I can find on directories for the last 2
weeks and none of them answer the question successfully on getting just
a list of directories; no filenames and not just . and ..
Any help greatly appreciated!