in reply to spaces removed in backreference
- You have a zero-length match (in $1), followed by space, followed byzero-length match ($2)
- use re 'debug'; to see exactly what your regex matches
- use a real HTML parser, like HTML::TreeBuilder or YAPE::HTML