in reply to ActiveState Perl: Forward or Backward Slash?

What is there to complain? The Win32 API understands both the forward and the backward slash as path separator (unlike the prevalent shell, cmd.exe). Of course, this makes writing scripts that check for file name equivalence harder, but if you're doing file name equivalence tests, you have the problem of a case insensitive (but case preserving) file system anyway.

So, depending on what your actual problem is (besides the aestethic), there is likely a solution in defining and then coding a normalization, but that normalization will likely depend on the OS and your requirements for equality.

  • Comment on Re: ActiveState Perl: Forward or Backward Slash?

Replies are listed 'Best First'.
Re^2: ActiveState Perl: Forward or Backward Slash?
by puploki (Hermit) on Sep 20, 2005 at 09:12 UTC

    Off topic a little but cmd does understand forward slashes:

    H:\>cd /perl H:\perl>

    A lot of command line utilties don't though, so your point is valid, in that if you use system() to run external Windows programs then you should probably use escaped backslashes unless you know it's going to work. I've been caught out a few times :)

      puploki's screen capture appears to demo cmd's behavior under WinXP;
      monarch asserts [perhaps just a tad abrasively] what I see under w2k (and, IIRC, earlier 'doze).
      What are you smoking?
      D:\Temp>cd /temp The syntax of the command is incorrect. D:\Temp>cd \temp D:\Temp>

      Updated: tested on WinNT

        What are you smoking?

        Clean air maybe? Tested with Windows XP

        C:\>cd /WINDOWS C:\WINDOWS> _

        Cheers, Sören

Re^2: ActiveState Perl: Forward or Backward Slash?
by saintmike (Vicar) on Sep 20, 2005 at 14:25 UTC
    Just because an external entity accepts both forms doesn't mean that two perl-internal functions should return the value of the same external entity in two different forms.

    You still wouldn't complain if caller() returned C:/foo/bar or C:\FoO\BaR, depending on if it's April 1st or not? ;)

    Seriously, the problem is that in the current implementation, it's unnecessarily complex to check the return value of caller() in a platform-independent way. File::Spec->catfile() offers this canonical way, but doesn't work in this case.