Re: Windows paths in glob
- From: Dmitry <mitia2008.remove@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 05:58:49 GMT
Martijn Lievaart <m@xxxxxxxxxxxxxxxx> wrote in news:pan.2008.03.30.19.27.16@xxxxxxxxxxxxxxxx:
On Sun, 30 Mar 2008 19:09:18 +0000, Dmitry wrote:
OK, so there's a well-known difficulty with handling Windows-style paths
in glob: it doesn't like backslashes, nor does it like spaces. One
solution to that is to use Unix-style paths:
glob('C:\Documents and Settings\*'); # Doesn't work glob('C:/Documents\
and\ Settings/*'); # Works
Problem is, the rest of Perl's built-in file-handling functionality
behaves the other way around. For instance, with -d:
-d 'C:\Documents and Settings'; # Works -d 'C:/Documents\ and\
Settings'; # Doesn't work
Question: is there any way to use the same path string with glob and
with the rest of Perl, without having to convert them back and forth?
I don't have Windows to test here, but I recall that using either a
forward slash '/' or a backward slash -- properly escaped -- '\\' works
either way in both situations.
In the examples you gave, the versions with backslashes cannot work, the
backslashes are not escaped.
M4
Spaces are a more serious problem than slashes. But anyway, the examples work,
because I used single quotes. BTW, current core glob seems to ignore backslashes
altogether, unless they escape something other than a backslash.
.
- References:
- Windows paths in glob
- From: Dmitry
- Re: Windows paths in glob
- From: Martijn Lievaart
- Windows paths in glob
- Prev by Date: Re: Windows paths in glob
- Next by Date: Re: Windows paths in glob
- Previous by thread: Re: Windows paths in glob
- Next by thread: Re: Windows paths in glob
- Index(es):
Relevant Pages
|