http://www.perlmonks.org?node_id=40832


in reply to Errors in File::Recurse()?

Windows paths in perl must look like this:
"c:\\folder\\folder"

Those crazy DOS people.

--=Lolindrath=--

Replies are listed 'Best First'.
RE: Re: Errors in File::Recurse()?
by myocom (Deacon) on Nov 10, 2000 at 02:16 UTC
    Actually, that's not-so-much true. Within Perl (and really, for many Win32 functions), 'c:/folder' is perfectly valid.
RE: Re: Errors in File::Recurse()?
by Fastolfe (Vicar) on Nov 10, 2000 at 02:20 UTC
    Or 'c:\folder\folder'. You only need to escape the back-slashes when you use them together (so you can still escape '): '\\\\server\share\dir\jack\'s file'
      Hehe...well, the unexpected behavior in this situation is that if you use a function that evaluates the path string and the first letter after a single backslash is an 'n' or some other command (e.g.: \n, etc.) then it evals that command and craps out your function. Forwardslash works fine on Win2k, dunno about other M$ products.

        Any function that "evalutates the path string" is pretty much broken in my book. Perhaps you could give us an example here. I suspect you might be confused as to how Perl deals with strings.

        Also, one other case where you need to double your backslash inside of single quotes (or the q{} operator) is if you want a backslash at the end of the string. I find not doubling your backslashes inside of single quotes to be a bad habit that leads to forgetting to double them in the cases when you need to (which leads to strange errors that can be very hard and time-consuming to find) and so I say always double your backslashes in single quotes.

        BTW, it would have been much nicer if single quotes had been defined so that you double the delimiter to include it in the string (like 'should''ve'). Then backslash would have no special meaning inside single quotes (unless you used it as the delimiter like q\this\). But it is too late to change that now.

                - tye (but my friends call me "Tye")