Hi jalopez453, welcome to the Monastery!
When asking a question of PerlMonks, please provide us some of your sample input data, and what your expected output would look like (both in <code></code> tags as you've done with your actual code).
I suspect what you're getting as output are all lines that contain M, but anywhere in the string, not just at the beginning. What you need to do is specify in your regex that you ONLY want to match if an M is at the start of your string. You do this by using the caret, aka ^ at the beginning of your regex:
my $find = '^M';
After that change is made, using this data:
no M at start
M at start
M at start again
another line, no M at start
I get this output:
M at start
M at start again
|