Thanks that worked great >>> [EMAIL PROTECTED] 06/30/04 12:22PM >>> Joe Stuart wrote: > I have a script that recursively goes through the filesystem and changes > links in html documents The problem I'm having is that it chokes on > directories with spaces in there names. Does anyone have any > suggestions on how to deal with this? I've tried using both glob and > readdir to go through the directory. Glob doesnt error out, but it > doesnt change the links in the documents and when using readdir I get > this error message. > Bad symbol for filehandle at ./recurse.pl line 15.
Here is some code I've posted before. I think it works with spaces. #!/usr/bin/perl use strict; use warnings; use File::Spec; scan_dir('.'); my @dirstack; sub scan_dir { my $dir = shift; return unless -d $dir; my @subdirs; opendir DIR, $dir or die "Can't open directory ($dir): $!\n"; while (my $file = readdir DIR) { next if $file eq File::Spec->curdir() or $file eq File::Spec->updir(); my $path = File::Spec->catfile($dir, $file); if (-d $path) { push @subdirs, $file; next; } else { # => do something here <= # print "$path\n"; } } closedir DIR; foreach my $subdir (@subdirs) { push @dirstack, $subdir; scan_dir(File::Spec->catdir($dir, $subdir)); pop @dirstack; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>