in reply to copy line with character
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: copy line with character
by jalopez453 (Acolyte) on Nov 23, 2015 at 18:54 UTC | |
by jalopez453 (Acolyte) on Nov 23, 2015 at 19:24 UTC | |
by stevieb (Canon) on Nov 23, 2015 at 19:37 UTC | |
by jalopez453 (Acolyte) on Nov 23, 2015 at 20:24 UTC | |
by stevieb (Canon) on Nov 23, 2015 at 20:33 UTC | |
by BillKSmith (Monsignor) on Nov 23, 2015 at 20:44 UTC | |
by jalopez453 (Acolyte) on Nov 23, 2015 at 20:55 UTC | |
by AnomalousMonk (Archbishop) on Nov 23, 2015 at 23:07 UTC | |
by stevieb (Canon) on Nov 23, 2015 at 21:01 UTC | |
by BillKSmith (Monsignor) on Nov 24, 2015 at 15:41 UTC |