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.
In reply to Re: globing files with spaces problem.
by kschwab
in thread globing files with spaces problem.
by Nabuku
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |