Re: Windows paths in glob



"John W. Krahn" <someone@xxxxxxxxxxx> wrote in
cGRHj.9264$9X3.7583@edtnps82:">news:cGRHj.9264$9X3.7583@edtnps82:

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?

perldoc File::DosGlob
perldoc File::Spec
perldoc File::Basename

I tried DosGlob, but when I passed it 'C:\Documents and Settings\*' it bugged out with an
error somewhere in the module...
.



Relevant Pages

  • Re: Windows paths in glob
    ... in glob: it doesn't like backslashes, ... solution to that is to use Unix-style paths: ... I don't have Windows to test here, but I recall that using either a ... In the examples you gave, the versions with backslashes cannot work, the ...
    (comp.lang.perl.misc)
  • Re: Open() and glob EXPR
    ... and perldoc -f open, and perldoc -f glob, but i am unable to make out ... If you had really read the glob perldoc, you would have seen that it ... A pipe lets you pass output from ... Would send anythig you print to FH on along to notepad. ...
    (perl.beginners)
  • Re: Windows paths in glob
    ... in glob: it doesn't like backslashes, ... solution to that is to use Unix-style paths: ... In the examples you gave, the versions with backslashes cannot work, the ... unless they escape something other than a backslash. ...
    (comp.lang.perl.misc)
  • Re: Windows paths in glob
    ... Dmitry wrote: ... like backslashes, ... One solution to that is to use Unix-style paths: ... 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? ...
    (comp.lang.perl.misc)
  • Re: Help with DOS file names
    ... perldoc -f opendir/readdir ... perldoc -f glob ... foreach $f (@dirs) { ...
    (comp.lang.perl.misc)