Finally, using readdir still gives me the file in ASCIIbetical order

use warnings; use strict; opendir my $d, "."; print "$_ \n" for readdir $d;
Result
. .. 1185398.pl 1188996.pl 1153280.serconf proj1.txt zipstest uri.pl 1189013.pl hash.pm days.pl 1185438.pl 1189178.pl hosts.pl 1189178a.pl 1185708.pl quake_pp.txt 1186032.pl dumper.txt 1186308.pl 1189211.pl 1186323.pl 1189235.pl 1186469.pl lookup.pl 1186032-b.pl 1189346.pl poj.pl 1189381.pl sqlite-tables.pl wmi-dbi.pl 1186518.pl 1189436.pl ... omitted for brevity

it gives you the relative path

readdir also gives you the relative path, relative to the directory you open

So the question is really: how does the file system returns the entries for a given directory?

Yes that is true. Some filesystems use a btree like structure, some filesystems place a new file into the next unused slot in the directory block, where a slot that had contained a deleted file is as eligible before the last block, some filesystems use the next slot that has room to contain the long file name. What order does the DIR command arrange files if no sort order is specified? About the order that readdir() returns entries in

I prefer readdir because it doesnt do things "behind the scenes" such as skip files that begin with a dot. The expression glob(".* *") matches all files in the current working directory.


In reply to Re^8: Duplicates in Directories by huck
in thread Duplicates in Directories by kel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.