in reply to Anchor parsing
You are trying to match a HTML link that is split over two lines, but you match your regex line by line!! So when the regex sees the first line it can't match because the closing tag is missing, then on the next line the opening tag is missing.
This is why perlmonks usually give the advice to use a module to edit HTML instead of using a simple regex. To remedy your situation you could put the whole html into one string, but then you will notice that the regex will eat anything between the first opening link tag and the last closing link tag. To remedy that you would change ".*" to ".*?" so that the minimal match is found instead of the longest match. But now and then your pattern will still fail because for example there could be a HTML comment with a closing link tag (which would be correct HTML but not a real closing tag).
|
|---|