in reply to Re^3: File:Find pattern match question
in thread File:Find pattern match question
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}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: File:Find pattern match question
by kcott (Archbishop) on Nov 01, 2013 at 03:31 UTC | |
by RockE (Novice) on Nov 02, 2013 at 12:36 UTC | |
by kcott (Archbishop) on Nov 03, 2013 at 05:07 UTC | |
by RockE (Novice) on Nov 03, 2013 at 11:52 UTC | |
by kcott (Archbishop) on Nov 13, 2013 at 16:44 UTC |