Well, for a given operating system (and possibly file system), either they do come in alphabetical order, or they don't. If they do for the OP's system, then presumably the OP can rely on that feature (although there can be some issues with the upper or lower case of the file names). And, BTW, I've just checked on the three different systems available to me (*nix, VMS and Windows), glob returned the names of the files in the directory in alphabetical system for all three of them, so, yes, it is a rather common feature.
Then, of course, as you rightly said, if they don't come in alphabetical order, or if there is any doubt, it is just as easy to use the Perl sort facility, and it will only take a few split seconds with 10,000 files.
The idea of sorting data to get better performance (avoiding lookups) is sometimes very efficient. I'm doing it quite commonly in a slightly different context, to compare pairs of very large files that would not fit in a hash: sorting both files on the comparison key (using the *nix sort utility), and then reading both files in parallel in my Perl program to detect records missing from either file or differences in attributes of records having the same comparison key.
| [reply] |
glob returned the names of the files in the directory in alphabetical system for all three of them,
I may be a caveman but id use readdir to get the file list and i think that it returns files in the order they are stored in the directory
| [reply] |
$ perl -E '@c = glob "*.*"; say for @c;'
1095341.pl
172.20.98.3.txt
8188eu-v7-20150914.tar.gz
a.exe
a.pl
abdou.pl
add2.pl
add_2.pl
age_switch.pl
amazon.pl
anagrams.pl
any.pl
any2.pl
any3.pl
aoh.pl
[... many lines omitted for brevity ...]
warnings.txt
weight.pl
while.pl
wifi.pl
words.txt
xml.pl
xml_mac.pl
xxxA.txt
xxxH.txt
xxxL.txt
$
| [reply] [d/l] |