> -----Original Message----- > From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl- > win32-users-boun...@listserv.activestate.com] On Behalf Of Brian Raven > Sent: Tuesday, December 13, 2011 8:36 AM > To: perl-win32-users@listserv.ActiveState.com > Subject: RE: File::Find::Rule problem > > > -----Original Message----- > > From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl- > > win32-users-boun...@listserv.activestate.com] On Behalf Of Ken Slater > > Sent: 13 December 2011 12:57 > > To: arvinport...@lycos.com; perl-win32-users@listserv.ActiveState.com > > Subject: RE: File::Find::Rule problem > > > > > -----Original Message----- > > > From: perl-win32-users-boun...@listserv.activestate.com > > > [mailto:perl- win32-users-boun...@listserv.activestate.com] On > > > Behalf Of arvinport...@lycos.com > > > Sent: Friday, December 09, 2011 4:33 PM > > > To: perl-win32-users@listserv.ActiveState.com > > > Subject: File::Find::Rule problem > > > > > > 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 > > > _______________________________________________ > > > > Hello, > > I had never used File::Find::Rule before, but I gave it a try. > > ActivePerl 5.8.9 Build 826. > > > > I set up a test with 3 files in the directory hierarchy: > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 Kland, Dan/test2.pl > > > > Then ran the following code: > > > > use strict; > > use warnings; > > > > use File::Find::Rule; > > my $ctr = 1; > > > > print "\n\n============== START =====================\n"; while (my > > $pattern = <DATA>) { > > chomp $pattern; > > > > my $rule = new File::Find::Rule (); > > > > my $subctr = 'a'; > > foreach my $modifiedPattern ( qr/\Q$pattern\E/, $pattern ) > > { > > my @exclude = ($modifiedPattern); > > > > print "\n=============================================\n"; > > print "== $ctr$subctr >>$exclude[0]<<\n\n"; > > > > $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 "$file\n"; > > } > > $subctr++; > > } > > $ctr++; > > } > > > > __DATA__ > > Kland, Dan > > (Kland, Dan) > > 84-33 > > 84-33 > > 84-33 (Kland, Dan) > > 84-33 Kland, Dan > > 84-32 > > > > This produced the output listed below > > > > ============== START ===================== > > > > ============================================= > > == 1a >>(?-xism:Kland\,\ Dan)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 1b >>Kland, Dan<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 2a >>(?-xism:\(Kland\,\ Dan\))<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 2b >>(Kland, Dan)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 3a >>(?-xism:84\-33)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 3b >>84-33<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 4a >>(?-xism:84\-33\ )<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 4b >>84-33 << > > > > D:/My Documents/projects/dave/test/should-print.txt > > > > ============================================= > > == 5a >>(?-xism:84\-33\ \(Kland\,\ Dan\))<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ > > > > ============================================= > > == 5b >>84-33 (Kland, Dan)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ > > > > ============================================= > > == 6a >>(?-xism:84\-33\ Kland\,\ Dan)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ > > > > ============================================= > > == 6b >>84-33 Kland, Dan<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ > > > > ============================================= > > == 7a >>(?-xism:84\-32)<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ D:/My > > Documents/projects/dave/test/84-33 Kland, Dan/test2.pl > > > > ============================================= > > == 7b >>84-32<< > > > > D:/My Documents/projects/dave/test/should-print.txt > > D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My > > Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ D:/My > > Documents/projects/dave/test/84-33 Kland, Dan/test2.pl > > > > ===== END OF OUTPUT ====== > > > > It appears that the parentheses are being ignored. > > The following names, produce the same results. > > And, they never seem to eliminate the directory with the parentheses. > > > > == 5a >>(?-xism:84\-33\ \(Kland\,\ Dan\))<< == 5b >>84-33 (Kland, > > Dan)<< == 6a >>(?-xism:84\-33\ Kland\,\ Dan)<< == 6b >>84-33 Kland, > > Dan<< > > > > Also, the following should not have excluded the directory "84-33 > > Kland, Dan", but it did. > > == 2a >>(?-xism:\(Kland\,\ Dan\))<< > > > > So, there does seem to be something amiss. > > > > Ken > > I have tried running both scripts without being able to reproduce the > problem. But then I am running Perl 5.14.1 and File::Find::Rule version > 0.33, so it could be version specific. > > I notice that the Changes file for the module has... > > 0.33 Monday 19th September, 2011 > Fixes the case where name("foo(*") hits an error with > mismatched > parentheis. Reported by Jan Engelhardt. > > It might be worth upgrading File::Find::Rule to the later version (Perl > as well, if you can). It might make a difference. > > HTH > > > -- > Brian Raven >
Yes, I tried it on a machine with ActivePerl 5.14.1 and File::Find::Rule 0.33, and it worked as expected. Ken _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs