Re: Windows paths in glob

Re: Windows paths in glob

am 31.03.2008 22:38:52 von Bart Lateur

Dmitry wrote:

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

Is a simple conversion acceptable?

If you put double quotes aroudn the path *in* the string for glob, then
it'll work.

($\, $,) = ("\n", "\t");
chdir 'c:/temp';
foreach('C:/Documents and Settings', 'C:\\Documents and Settings') {
print $_, glob(qq("$_")), -d $_ || 0;
}

Result:

C:/Documents and Settings C:/Documents and Settings 1
C:\Documents and Settings C:./Documents and Settings 1

Well, ok... the response of glob to a backslash *is* weird. But at
least, it seems to work.

--
Bart.

Re: Windows paths in glob

am 31.03.2008 22:57:55 von Ben Morrow

Quoth Bart Lateur :
>
> Result:
>
> C:/Documents and Settings C:/Documents and Settings 1
> C:\Documents and Settings C:./Documents and Settings 1
>
> Well, ok... the response of glob to a backslash *is* weird. But at
> least, it seems to work.

Not just weird: wrong. Win32 has a notion of 'current directory on a
given drive'; C:./Documents and Settings is a path relative to the
current directory on drive C:.

Ben