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. |