Great info! On older versions of Windows, it didn't work that way, but you are correct on Win XP.

Update: not quite right...

C:\PROJECTS\xyz2009>cd c:/projects The system cannot find the path specified. C:\PROJECTS\xyz009>cd c:\projects C:\PROJECTS>
Another Update:
Revising my post in response to ikegami's post.
Apologize for being too cryptic.

1. First there are a whole lot of Windows things between Win 3.1 and Win XP: Win 98, WinNT, Win2K. I was thinking more about NT and 2K when I made the comment about previous versions of windows. At one time I had all 4 versions (98,NT,2K,XP) on my network for testing, but am down to just XP now. There are lots of quirks between these various versions.

2. I did some testing at the command prompt on XP and found:

C:\> C:\>cd projects/replyto C:\PROJECTS\replyto>
That was a "WOW" moment as I hadn't expected that forward slash to work with the cd command! But it did!

3. Then I found out that there is something special about the Drive: root- the forward slash doesn't work in this situation:

C:\PROJECTS\replyto>cd c:/projects The system cannot find the path specified. (didn't work) C:\PROJECTS\replyto>cd c:\projects (does work) C:\PROJECTS>
That little discovery is what prompted the update: "not quite right" comment.

4. More examples:

C:\PROJECTS>type testing/test.pl (doesn't work) The syntax of the command is incorrect. C:\PROJECTS>type "testing/test.pl" (doesn't work either) The system cannot find the file specified. C:\PROJECTS>type "testing\test.pl" (works) C:\PROJECTS>type testing\test.pl (works) C:\PROJECTS>cd ./testing (works) C:\PROJECTS\testing> C:\PROJECTS>cd /testing (works) C:\PROJECTS\testing>
Evidently sometimes the "forwards slash" works at the command line and sometimes it doesn't. There appears to be something special about drive root and I suppose some of these commands like "type" can get confused between path and "/" options.

5. In an attempt to try and avoid confusion, when writing Perl, I always use forward slash. That works with all Perl functions even with a path like c:/projects. As long as you don't go the the shell with say a command('blah'), forward slash is the way to go.


In reply to Re^3: Trouble using a Win32 file path in an array by Marshall
in thread Trouble using a Win32 file path in an array by geo

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.