[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?

Hmmm try this, works for me:

perl -we 'print join " ", glob("*");'

I prefer:

perl -we 'print $_,"\n" foreach(glob("*"));

File::Find might be a good choice for this task.

Juan Fuentes 
--
As far as the laws of mathematics refer to reality they are not certain; and as
far as they are certain; they do not refer to reality."
- Albert Einstein



Reply to: