Eliminate that loop

(311 strokes) Eliminate the while(<>) construct with -n, and eliminate chomp, etc., with -l.
#!perl -nl
sub maybe_print_m {
	unless ($DONE_M) {
		print "$PREFIX.M";
	}
}
$PRINTED_LINE = 1;
unless (/$PREFIX/) {
	maybe_print_m;
	$DONE_M = 0;
}
my $s;
($PREFIX, $s) = split /\./, $_, 2;
if (/[M-Z]$/) { 
	unless (/M$/) {
	    maybe_print_m;
	}
	$DONE_M = 1;
}
print;
END {
	maybe_print_m if $PRINTED_LINE;
}