Hi List, I've worked with Perl on Unix for years, still a beginner on windows.
I have a script that recursively travels down a file and directory tree and captures file stats. Works fine on Solaris. The script has a problem when it hits a directory or filename containing spaces. I'll paste the subroutine code below; I borrowed from Mark Jason Dominus' "Higher Order Perl" Basically, this is a recursive subroutine. You feed it some directory that gets populated into the variable $top (eg, C:\path\to\some dir), as well as feed it a couple of callbacks. The code below breaks down when it hits the test operator -d and $top contains a directory with a space (/some dir/). The test operator doesn't seem to recognize the directory-with-space as a directory, so the whole if condition is bypassed. I've played with such things as putting quotes around the offending directory, around the whole path, etc., with no joy. The best he does is read the toplevel directory handed to him, but then he stops. I need a more robust way of handling this strange filesystem. =========================================== Here's the code: sub dir_walk { my ($top, $filefunc, $dirfunc) = @_; my $DIR;, if ( -d $top ) { # << FAILS HERE my $file; unless (opendir $DIR, $top) { warn "Couldn't open directory $top: $!; skipping.\n"; return; } my @results; while ($file = readdir $DIR) { next if $file eq '.' || $file eq '..';; push @results, dir_walk("$top/$file", $filefunc, $dirfunc); } return $dirfunc->($top, @results); } else { return $filefunc->($top); } } =========================================== best, /dennis ------------------------------------------------ Dennis Daupert, PhD Senior Systems Development Professional -- CSC Account CSC GOS | o: 1.317.298.9499 | [EMAIL PROTECTED] | www.csc.com This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs