in reply to Re: Recursive sub efficiency
in thread Recursive sub efficiency

Yep your right Im only interested in the folders nothing else.

However the inline grep and directory check does not return any anything. Ive updated the directory handle to a scaler as per Ikegami's advice.

my @files = grep(/\w/,readdir($fh)); #returns folder & files my @dirs = grep {/\w/ and -d} readdir($fh); #returns blank

Replies are listed 'Best First'.
Re^3: Recursive sub efficiency
by ikegami (Patriarch) on Jun 10, 2010 at 20:27 UTC
    He meant
    my @dirs = grep { /\w/ && -d "$dir/$_" } readdir($dh);
    which should probably be
    my @dirs = grep { !/^\.\.?\z/ && -d "$dir/$_" } readdir($dh);
Re^3: Recursive sub efficiency
by toolic (Bishop) on Jun 10, 2010 at 20:23 UTC
    My mistake. I updated my code.

    Comment out your @files line, then @dirs should contain something. You can not call readdir two times like that.