my @files = <*.txt>; undef $/; foreach (@files) { open ( FH, $_ ); my $txt = ; close ( FH ); while ( $txt =~ m/(M[A-Z]{3}) /gs ) { print " $1\n"; } }