The big problem is that the tool you're using (regular expressions) is terribly bad at parsing things like HTML. I'd strongly recommend one of the HTML parsing modules (HTML::Parser or HTML::TreeParser) to do this job. They take care of the messy business of actually understanding the HTML and let you concentrate on stuff like "I want the contents of this tag".
Comment on Re: getting and printing form values etc from html stripping out all else
Thank you i've looked over the links and the info for the HTML::Parser etc, however I am unsure how to implement it into my current code. I am fairly new to this. I'll keep reading into it, anymore assistance will be appreciated.