# simplified a lot, but basically sub find { my ($opts, @dirs) = @_; $opts = wrap_wanted ($opts); my $wanted = $opts->{wanted}; my $finder = File::Find->new($opts, @dirs); while (my $file = $finder->next) { local $_ = $file; local ... # etcetera &$wanted } }