print
#!perl -pl sub maybe_print_m { $DONE_M || print "$PREFIX.M"; } /$PREFIX/ or$DONE_M=!maybe_print_m; /\./; $PREFIX=$`; $DONE_M=/M$/ || maybe_print_m if /[M-Z]$/; END { $.&&maybe_print_m }