$dirs{$File::Find::name} = 1;
in sub dir_names is bogus. The following increment line does all the work required.
Update: Oh, and you probably want to compare just the directory name instead of the full path so you probably want to use $_ for the hash key. Actually, even better is to keep a list of full paths by directory name so you can see the full path of all duplicated directories:
#!/usr/bin/perl # dirdupes use strict; use warnings; use File::Find; #*****************Path Variables********************** our $testpath = 'E:\scratch~~\Lin\App\KuraCloud'; #******************************************************* my %dirs; find(\&dir_names, $testpath); my @dup_dirs = grep {$dirs{$_} > 1} sort keys %dirs; foreach my $name (@dup_dirs) { next if @{$dirs{$name}} == 1; print "$name:\n"; print " $_\n" for @{$dirs{$name}}; } sub dir_names { return if ! -d || ! /[IPD]\d{8}$/; push @{$dirs{$_}}, $File::Find::name; }
In reply to Re: Using file::find to find dupe dirs
by GrandFather
in thread Using file::find to find dupe dirs
by RockE
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |