Thanks to all monks who responded. It is not a bug after all, and I did miss something subtle.

Corion pointed out that command.com and cmd.exe keep a current directory for every drive - I knew that from experience.
japhy added that in Windows (aka command.com and cmd.exe), typing dir c: lists the current directory of drive c: - I never noticed that before.
Hence my erroneous belief that typing dir c: would list the root directory.

This being so, it makes sense that Perl's opendir("c:") opens the current directory of drive c:, not the root directory.

I also looked into Perl sources (AS build 618). In win32\win32.c: win32_opendir() I found the code that performs the mapping "c:" to "c:./":
/* bare drive name means look in cwd for drive */ if (len == 2 && isALPHA(scanname[0]) && scanname[1] == ':') { scanname[len++] = '.'; scanname[len++] = '/'; }
The C comment says what the code does, but not why. japhy explained why.

Rudif

PS The conclusion ought to be RTFM, except that I still don't know which FM I should have read.


In reply to Re: Problem with opendir/readdir on Win2k by Rudif
in thread Problem with opendir/readdir on Win2k by Rudif

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.