in reply to Help with the push function

The basic problem with this approach is that regular expressions, as their name implies, can only express a regular grammar. But HTML, like all SGML and XML applications, is a context-free grammar, and thus can't always be parsed with regular expressions.

What you need to do is use HTML::Parser or a similar CPAN module, that's designed for the task at hand.