in reply to Re^2: Return multiple matches in file
in thread Return multiple matches in file

At minimum change your string to $string = quotemeta 'String to search for';. quotemeta, which ensures that $string is interpreted as a literal string, rather than having the characters you're searching for be mistakenly seen as regexp special characters.

But just a couple days ago I was playing with HTML::LinkExtor, and I have to say, I think it's a much more robust solution for what you're trying to accomplish. It wouldn't exactly fit your specification, but it would probably be such a nice solution that you would reconsider how to solve the greater problem.

By the way, that code you found in Categorized Questions and Answers is... well, at best outdated. That's why I was asking. Embarrassing that it still sits there in Q&A. I took the liberty of updating the Q&A post with some more up to date code.


Dave