find( sub { get_dirs( \@list_of_dirs, $_ ) }, $root_path); sub get_dirs { my ($dirs_aref, $current_path) = @_; my $abs_path = abs_path($current_path); my $file = $abs_path."/"."secret.file"; my $ignore_file = $abs_path."/".".ignore"; push (@{$dirs_aref},$abs_path) if((-e $file) && !(-e $ignore_file)); }