in reply to globing files with spaces problem.
Long Answer:
I get the same problem. At first, it appears to be a bug. Supposing the following directory tree:
And the following code:/dir1/file1 /dir two/file2
I get back 'dir' and 'dir1/file1'. Strangely enough, if I use File::Glob's bsd_glob, it works just fine:foreach my $dir (glob("*")) { foreach my $file (glob("$dir/*")) { print "[$file]\n"; } }
So, I looked at the docs and found that it's working as documented :)use File::Glob qw(bsd_glob); foreach my $dir (bsd_glob("*")) { foreach my $file (bsd_glob("$dir/*")) { print "file [$file]\n"; } }
Since v5.6.0, Perl's CORE::glob() is implemented in terms of bsd_glob(). Note that they don't share the same prototype--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 pat tern.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: globing files with spaces problem.
by Nabuku (Initiate) on Aug 10, 2002 at 17:37 UTC | |
by kschwab (Vicar) on Aug 10, 2002 at 17:42 UTC | |
by Nabuku (Initiate) on Aug 10, 2002 at 20:13 UTC | |
|
Re^2: globing files with spaces problem.
by Anonymous Monk on May 08, 2009 at 15:16 UTC |