my %search_for; $search_for{$_} = 1 for @input_array; find({ wanted => \&edits}, $dir); print "Couldn't find these files: ", join(', ', keys %search_for), "\n"; sub edits { my $file = $_; if ($search_for{$file}) { print "Found $file, we were looking for it!\n"; delete $search_for{$file}; # do the copying etc. here } }