in reply to slash converter

You do know that Win32 systems can use forward slashes, right? c:/windows/temp is valid.

Replies are listed 'Best First'.
RE: RE: slash converter
by Adam (Vicar) on May 25, 2000 at 21:58 UTC
    <quote>"You do know that Win32 systems can use forward slashes, right? c:/windows/temp is valid."</quote>
    This is no longer true. Win2K does not support the forward slash anymore. It assumes that you are refering to a flag of somekind and bombs out with an error.

    UPDATE: Since KM does not believe me that Win2K will bomb I went back to my W2K box and ran a simple test. I opened a command prompt at the C:\ level and called
    dir c:\perl5
        and
    dir c:/perl5
    and what-do-you-know! The first method (backslash) returned the contents of the perl5 directory and the second method (forward-slash) generated the error:

    Parameter format not correct - "perl5".

    I hope this is sufficient information for you KM.

      Does this apply to both Perl functions and command-line arguments, or just the CLI? "Switches" in filenames is particularly useless, so I wonder if an open(F, "/somedir/filename.txt") would work identically on Unix and Win2k?
        (posted by request from chatterbox)

        Yes, it works the same on Win2k. Of course, it will assume the root on the current drive letter, though (use chdir to change drive letters).

        Here's an example to illustrate the point:
        #!perl -w use strict; # always open(F,">/temp/foo.txt") or die "Unable to open temp file for write: $!\n"; print F "This is a test. This is only a test.\n"; close(F); open(F,"/temp/foo.txt") or die "Unable to open temp file for read: $!\n"; while (<F>) { print "foo: $_"; } close(F); unlink ("/temp/foo.txt");
        ...which outputs:
        foo: This is a test. This is only a test.


        Cheers,
        Shendal

      Because I work in Perl exclusively on a win2k box, run scripts from that box daily that use the forward slash, and only use the forward slash b/c I hate writing \\\\ before a server, you can mark me a dissenter.

      The forward slash absolutely works with an install of ActiveState 6.15 on a win2k box

      Update:I did something like the original post in this thread here

      -OzzyOsbourne

        Of course, you can avoid escaping back-slashes by putting everything in single-quotes, but that makes variable interpolation somewhat messy.
      FWIW, dir "C:/TEMP" does work.

      Cheers,
      Shendal
      I feel lucky that I wouldn't know that Win2K no longer supports this. However, I would need to see it to believe it. I do know that 98/NT does support this.

      Cheers,
      KM