Thank you for your answer. Well, I very much prefer to use
glob (rather than readdir) when I can for a number of reasons, the main one being that it gives you the relative path (making coding easier), another one that it takes only one code line instead of two (or even three if you close the dir handle), and finally that it removes some special directories. And we have no idea on how the OP is retrieving the files in the relevant directory.
I am not sure what "the files in the order in which they are stored in the directory" really means; as as I can say, the files are not stored in any specific order on disk (they may even be scattered on non continuous blocks), it is the file system (FAT, ext2, ext3, NTFS, etc.) which may give some sort of order to the collection of files. So the question is really: how does the file system returns the entries for a given directory?
Finally, using readdir still gives me the file in ASCIIbetical order (or, at least, in a pseudo-alphabetical order which is perfectly suitable for the proposal made by AnoMonk):
$ perl -E 'opendir $d, "."; say $_ for readdir $d;'
.
..
,
----------------------------------------------------------------------
+--------------
.bashrc
.bashrc~
.bash_history
.bash_profile
.cpan
.emacs.d
.inputrc
.joe_state
.lesshst
.minttyrc
.perldb_t
.profile
.ssh
1000
1095341.pl
172.20.98.3.txt
2000
500
8188eu-v7-20150914.tar.gz
a.exe
a.pl
abdou.pl
Acme
add2.pl
add_2.pl
age_switch.pl
[many lines omitted for brevity]
xml.pl
xml_mac.pl
xxxA.txt
xxxH.txt
xxxL.txt
X_oper.pl
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.