in reply to Finding files in a directory tree from and array of file names

Thanks everyone for your help. Making targetfind anonymous within find was the key.
My code is now:
use File::Find; use strict; my @directory = ("\src"); my @sourcefiles; my $srcfile; find(\&sourcefind, @directory); sub sourcefind { open(FL, $File::Find::name); push @sourcefiles, $_ if -f and /\.htm*/ ; close(FL); } foreach $srcfile (@sourcefiles) { find( sub {print "$_ target found\n" if -f and /\Q$srcfile\E/;}, 'D:\Projects\perl\targ'); }

Replies are listed 'Best First'.
Re: Re: Finding files in a directory tree from and array of file names
by tommyw (Hermit) on Oct 15, 2001 at 17:10 UTC

    As long as you've got unique filenames across all your dictories...

    Since you're no longer storing the path name, subdir1/file.htm and subdir2/file.htm will both be stored simply as file.htm. When you find a file called file.htm below the target directory, it will appear to match both of these.

    This isn't necessarilly a problem, as long as you're aware of the possibility.