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?
touch 'this and that'
perl -e 'print join ":",glob("*")'
eek. doesn't look good.
perl -e 'opendir DIR,".";print join ":",grep/.*/,readdir DIR'
better, but uses regex instead of glob patterns.
or, maybe try
use File::Find;
my @list = ();
find( \&iterator , "./path/one" , "/another/path/here");
&munge( @list );
sub iterator {
push @list,$File::Find::name
if $File::Find::name =~ m{$pattern}o
or &conditions_are_just_so($something);
}
see the camel book for more on File::Find.
--
DEBIAN NEWBIE TIP #30 from Will Trillich <will@serensoft.com>:
Which COMMANDS pertain to <xyz>? Try "apropos <xyz>",
"info <xyz>", and "man -k <xyz>".
Also see http://newbieDoc.sourceForge.net/ ...
Reply to: