I hate to be a stickler for details, but are you actually looking to find the text,
/_theWord/ or are you looking to find text embedded in that format. If you are looking the
/theWord/, then this should do you just fine (notice the
~ in the
=~ which you left out in your code):
my @matched_lines;
push (@$matched_lines, $matcher)
if ($matcher =~ /^.*_theWord$/);
Also, but using an array, you can catch multiple matches in the same line. If you are looking for another grouping of text, then just reformat the regex for what you are looking for. Either that, or provide us a little more information so we can help you.
Update: Upon another glance, I noticed that you are using multiple '/' in your regex. The first '/' begins the regex and the second '/' terminates it. Therefore, I believe your intended regex was something along the lines of $matcher =~ /\w\w_\w(.+?)/; However, this would still not match your data as the \w doesn't work the way you are thinking it does. I would recommend that you read perlretut or at least perlrequick to get a better understanding of regular expressions.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.