in reply to Get folders in a directory with 20k directories?

First off, define "slow."

Secondly there are a lot of factors here that could affect your timing trying to do what you are doing. My immediate solution in Perl would be something along the lines of:

| | stuff before opendir(DIR,"/some/path/where/the/folders/live") or die $!; my @folders=(); while(my $entry = readdir(DIR)){ next if ( $entry eq "." ) || ($entry eq ".." ); next unless -d $entry; push @folders,$entry; } | rest of code # untested software, do not use to aim phaser banks.

But wait, if you are having performance issues using the "ls" command then we have to consider one or more of the following factors:

It would seem to me that if "ls" is having an issue with performance acting on that collection of folders then anything you might use to emulate "ls" is going to have issues as well.

In my mind this is less of a Perl or scripting issue and more of a system issue.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg