Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

RE: RE: slash converter

by Adam (Vicar)
on May 25, 2000 at 21:58 UTC ( [id://14834]=note: print w/replies, xml ) Need Help??


in reply to RE: slash converter
in thread slash converter

<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.

Replies are listed 'Best First'.
RE: RE: RE: slash converter
by Fastolfe (Vicar) on Oct 13, 2000 at 21:46 UTC
    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
        In write-mode also? E.g. open(F, ">/somedir/filename.txt") In other words, does it correctly create this new file as c:\somedir\filename.txt?

        (Update: The original node was updated, answering this question.)

RE: RE: RE: slash converter
by OzzyOsbourne (Chaplain) on Oct 13, 2000 at 22:25 UTC

    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.
        One of the (for me) more annoying gotchas. Inside a single-quoted string, \ is still special. '\\' is just a single \, and '\'' is a single-quote.

        So if you need to, by chance, wind up with \\, even with a single quote you still find yourself doing \\\\.

RE: RE: RE: slash converter
by Shendal (Hermit) on Oct 13, 2000 at 22:27 UTC
    FWIW, dir "C:/TEMP" does work.

    Cheers,
    Shendal
RE: RE: RE: slash converter
by KM (Priest) on May 25, 2000 at 22:05 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://14834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-20 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found