#!/usr/bin/perl -w =head1 Command: duofind srcdir destdir Descends srcdir and reports only files that also exist in destdir. It does NOT report files that DO NOT exist in destdir, nor does it report files in destdir that do not exist in srcdir. =cut use File::Find; use Cwd; sub cmp { return if -d; $file2 = $_; if ($file1 eq $file2) { print "### Found in $File::Find::dir/$_\n" } } sub doit { my $f = shift; opendir DIR, $f || die "can't open $f"; foreach my $file (readdir DIR) { next if ($file eq "." || $file eq ".."); if (-d "$f/$file") { doit("$f/$file"); next } $file1 = $file; $src = $f; print "Looking for $src/$file1\n"; find({ wanted => \&cmp }, $dest); } close DIR; } die "need a src dir" if (!($src = shift)); die "need a dest dir" if (!($dest = shift)); die "src cannot equal dest" if ($src eq $dest); doit ($src);