in reply to File:Find pattern match question
Hello RockE,
As you don’t actually ask a question, I’ll have to guess that you want a way to remove duplicate directories from your output. Here is one approach:
... my %dirs; find(\&dir_names, $wellpath); print "$_\n" for sort keys %dirs; 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} = 1; }
That is, instead of printing each directory as it is found, store it in a hash and print the hash keys after the call to find has completed. As hash keys are necessarily unique, no duplicates will be recorded.
Hope that helps,
Update: See the correction below.
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File:Find pattern match question
by RockE (Novice) on Oct 31, 2013 at 06:17 UTC | |
by kcott (Archbishop) on Oct 31, 2013 at 06:58 UTC | |
by RockE (Novice) on Nov 01, 2013 at 01:00 UTC | |
by kcott (Archbishop) on Nov 01, 2013 at 03:31 UTC | |
by RockE (Novice) on Nov 02, 2013 at 12:36 UTC | |
| |
|
Re^2: File:Find pattern match question
by RockE (Novice) on Nov 01, 2013 at 00:50 UTC | |
by Athanasius (Archbishop) on Nov 01, 2013 at 02:22 UTC | |
by RockE (Novice) on Nov 02, 2013 at 12:06 UTC | |
|
Re^2: File:Find pattern match question
by Anonymous Monk on Mar 24, 2016 at 02:22 UTC | |
by Anonymous Monk on Mar 24, 2016 at 02:33 UTC |