in reply to Weird situation...

The general answer is "Parsing HTML is hard. Use a tool for it." Have a look on CPAN, there are plenty of HTML modules there. HTML::Sanitizer or HTML::Parser is likely most useful in this case.


Perl is environmentally friendly - it saves trees