[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [perl] glob() and filenames w/ spaces



On Wed, Apr 25, 2001 at 01:37:39AM +0200, Sven Burgener wrote:
> Hi all
> 
> Sorry if this is too off-topic, but on debian-user there is usually
> excellent help, so I cannot resist. =)
> 
> How do I deal with the situation where glob("*") is used and where there
> are files that contain spaces in their file names?
> 
> I know spaces in file names suck. I have no choice. It's the way it is.
> 
> What I like about glob() is that it returns the whole path as opposed to
> readdir(DIR) which only returns the top of the path.
> That is very useful for my situation, so I need this property.
> 
> So, is there any way to make glob("*") smart about files with spaces in
> their names?
> 
> Has anyone dealt with something similar before?

afaik, it depends on the perl version whether spaces in filenames will cause
problems. Perl-5.004 was buggy in that respect, while perl-5.005_03 and
perl-5.6.x work correctly:

$ ls -1
test 1.dat
test 2.dat

with version 5.004 you get:
$ perl -e 'print join "\n",glob("*")'
test
1.dat
test
2.dat

with both 5.005 and 5.6 you get (at least I do here...):
$ perl -e 'print join "\n",glob("*")'
test 1.dat
test 2.dat


-- 
Erdmut Pfeifer
science+computing ag

-- Bugs come in through open windows. Keep Windows shut! --



Reply to: