Hi Ken I tried your example but it wouldn't output anything. If I removed the pattern match string it does work but I'm not sure what it is printing out - the directory listing seems random.
#!/usr/bin/perl # dirpathdupes use strict; use warnings; use File::Find; use Fcntl; #*****************Path Variables********************** our $wellpath = 'N:\\repos\\open\\Wells\\Regulated\\'; our $surveypath = 'N:\\repos\\open\\Surveys\\Regulated\\'; our $testpath = 'C:\\Temp\\'; #******************************************************* my %dirs; find(\&dir_names, $testpath); my @dup_dirs = grep { $dirs{$_} > 1 } keys %dirs; #print "$_\n" for sort keys %dirs; foreach my $l (@dup_dirs) { print "$l\n"; } sub dir_names { # skip over everything that is not a directory return unless -d $File::Find::name; # skip over directories that don't match required pattern return unless $File::Find::dir =~ /[IPD]\d{8}$/; ++$dirs{$File::Find::dir}; }
In reply to Re^4: File:Find pattern match question
by RockE
in thread File:Find pattern match question
by RockE
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |