Re: Windows paths in glob

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.
Bart Lateur [ Mo, 31 März 2008 22:38 ] [ ID #1931927 ]

Re: Windows paths in glob

Quoth Bart Lateur <bart.lateur [at] pandora.be>:
>
> 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
Ben Morrow [ Mo, 31 März 2008 22:57 ] [ ID #1931930 ]
Perl » comp.lang.perl.misc » Re: Windows paths in glob

Vorheriges Thema: glade whit multiple windows
Nächstes Thema: Re: printf: zero pad after the decimal a given amount