Getting the names for >200 directories

Discussion in 'Perl Misc' started by frankthechicken@gmail.com, Aug 26, 2008.

  1. Guest

    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
    , Aug 26, 2008
    #1
    1. Advertising

  2. Guest

    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.
    , Aug 26, 2008
    #2
    1. Advertising

  3. <> wrote:

    > 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?


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Aug 27, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Finkel
    Replies:
    0
    Views:
    490
    Joel Finkel
    Sep 12, 2003
  2. Jeffry van de Vuurst
    Replies:
    2
    Views:
    523
    Jeffry van de Vuurst
    Jul 30, 2003
  3. Elhanan
    Replies:
    0
    Views:
    548
    Elhanan
    Aug 3, 2005
  4. Geoff Cox
    Replies:
    20
    Views:
    283
    Geoff Cox
    Aug 19, 2003
  5. Adam Petrie
    Replies:
    8
    Views:
    305
    Adam Petrie
    Oct 11, 2004
Loading...

Share This Page