my @mlc; sub wanted { return unless $_ eq 'mlc'; push @mlc, $File::Find::name; } find(\&wanted, '.'); foreach my $file (@mlc) { open(my $fh, $file) or die "Can't open '$file': $!"; # per-file code goes here }