For a start, let us drop the -d test, in order to see things... See also Paladin's reply. But, there's still more going on.

Windows (and DOS) is a bit strange with regards to directories and drives: each drive has its own internal current directory. You can see it at the DOS prompt too: type cd d:\files for whatever directory that exists there, if your currently on drive C: you'll still see the path on C: as a prompt. You need to type D: to change that.

Run your script from that prompt, with C: as your current drive, and you'll see different files listed for every directory you chdir'ed to. Really.

In other Windows languages, you need to use a separate function call to change the current drive, and the current directory on a drive.

You commonly don't notice anything in Perl, because chdir (and Cwd's cwd) changes/report both drive and directory at once.

Conclusing: even in Perl, don't use "d:"; use a full path, like "d:\\" or "d:/", "d:\\files" or "d:/files".


In reply to Re: Directory path and -d?? by bart
in thread Directory path and -d?? by pen

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.