in reply to parsing a line with $1, $2, $3
Your data looks like it's HTML, in which case you might get better results using an HTML parser.
I'd use HTML::TreeBuilder but there are other options ;)