Re: Problem with glob and filenames containing '[' and ']'
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxx
- Date: 27 Sep 2006 17:33:12 GMT
David Squire <David.Squire@xxxxxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
anno4000@xxxxxxxxxxxxxxxxxxxxxx wrote:
David Squire <David.Squire@xxxxxxxxxxxxxxxxxxxx> wrote incomp.lang.perl.misc:
Hi folks,
I'm having trouble using glob to find filenames that contain '[' and
']', even though I am escaping those meta-characters. Here is an example
script and output:
I don't know what goes wrong for you. It works for me as expected
(after replacing /damocles/documents/ENH1260/2006/2/Short assignment/
with something that exists on my box).
Thanks. Would you be able to try my second, simpler, example too? That
seems to narrow down the oddness.
Well yes, it's the blank in the path name that does it. Here is the
relevant bit from File::Glob, which implements CORE::glob():
Since v5.6.0, Perl's CORE::glob() is implemented in terms of
bsd_glob(). Note that they don't share the same proto-
type--CORE::glob() only accepts a single argument. Due to historical
reasons, CORE::glob() will also split its argument on whitespace,
treating it as multiple patterns, whereas bsd_glob() considers them as
one pattern.
So it's not a bug. The solution would be to use File::Glob::bsd_glob()
directly.
Anno
.
- Follow-Ups:
- Re: Problem with glob and filenames containing '[' and ']'
- From: David Squire
- Re: Problem with glob and filenames containing '[' and ']'
- References:
- Problem with glob and filenames containing '[' and ']'
- From: David Squire
- Re: Problem with glob and filenames containing '[' and ']'
- From: anno4000
- Re: Problem with glob and filenames containing '[' and ']'
- From: David Squire
- Problem with glob and filenames containing '[' and ']'
- Prev by Date: Re: Passing object from subroutine problem
- Next by Date: Re: Problem with glob and filenames containing '[' and ']'
- Previous by thread: Re: Problem with glob and filenames containing '[' and ']'
- Next by thread: Re: Problem with glob and filenames containing '[' and ']'
- Index(es):
Relevant Pages
|