in reply to Find part of string
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.
|
|---|