Getting the names for >200 directories

F

frankthechicken

I am attempting to either put into an array, or just iterate through
all the names of the directories I have.

I can do this with:-

my @dir_names = grep -d "$path/$_", readdir DIR;

or

opendir(DIR, $path) or die "cant find $path: $!";
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
if (-d "$path$file"){

However there are > 200 directories, and there seems to be a hard
limit of 200 when I try to store or iterate through.

Is there any way round this, and why does it occur?

Many thanks
 
F

frankthechicken

OK, seems like its a problem elsewhere in the code as I did a quick
little test of both methods on their own, and they seem to work fine.
 
T

Tad J McClellan

my @dir_names = grep -d "$path/$_", readdir DIR; ^
^

while (defined(my $file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
if (-d "$path$file"){
^^

Where is the directory separator?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,930
Messages
2,570,072
Members
46,521
Latest member
JamieCooch

Latest Threads

Top