I have a real head scratcher trying to exclude directories with File::Find:Rule 
version 0.32.

I have made a small test directory on my Windows XP machine with the following 
two files:

D:\My Documents\projects\dave\test\log.txt
D:\My Documents\projects\dave\test\84_33 (Kland, Dan)\test.pl

I want to exclude the Kland directory and just return log.txt (I know I can set 
the depth of the find - this is just an illustrative problem for a much larger 
directory structure).

Here is my test program:

use File::Find::Rule;
use strict 'vars';

my $rule =  new File::Find::Rule ();
my @exclude = (qr/Kland, Dan/);
$rule->or(
   $rule->new->directory->name(@exclude)->prune->discard,
   $rule->new
);

my @files = $rule->file->in('D:\My Documents\projects\dave\test');

foreach my $file (@files) {
   print STDERR "$file\n";
}

It works as it should, only returning log.txt

However if I make certain changes to the exclude regex it fails (i.e., the 
program runs fine but returns both files, including test.pl which it should 
not).

This works: my @exclude = (qr/\(Kland, Dan\)/);
This works: my @exclude = (qr/84_33/);
So does this (with a space at the end): my @exclude = (qr/84_33 /);
This does not: my @exclude = (qr/84_33 \(Kland, Dan\)/);
This doesn't work either (adding a single space in front): my @exclude = (qr/ 
\(Kland, Dan\)/);
And this crashes with a lengthy File::Find::Rule compile error: my @exclude = 
(qr/84_33 \(/);

So, it's not the spaces, it's not the parentheses, it's ... something.

Can anyone see what I'm doing wrong, or at least replicate the problem?

Arvin

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1004 [287188] provided by ActiveState http://www.ActiveState.com
Built Sep  3 2008 13:16:37
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to