If you are interested in the actual '*quickest* way to get a list of all folders in a directory' on Windows then you'll need either an XS extension or external C program *.
Why? Because the pure Perl code typically used to do this task of opendir/readdir/-d will make unnecesary extra system calls. At the Win32 API level Perl's readdir is done by FindNextFile() which returns a WIN32_FIND_DATA structure that contains whether the returned file is a directory. Unfortunately this info is not kept so you must then stat() it to test if it's a directory. This extra work can amount to a significant overhead.
And also remember to: ${^WIN32_SLOPPY_STAT} = 1; to avoid more extraneous system calls (unless you are actually interested in the link count of stat'd files!)
* I use qfind to efficiently find all the files in a directory. Modifying it to do what you want is left as an exercise :-) You can find it at http://backpan.perl.org/authors/id/A/AD/ADAVIES/qfind.c-1.06
alex.
In reply to Re: Quickest way to get a list of all folders in a directory
by Clarendon4
in thread Quickest way to get a list of all folders in a directory
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |