I had to do something like this, and I used HTML::TokeParser, which I had to learn myself in my advanced state of newbieness. Luckily though, the newbies of today can use crazyinsomniac's excellent tutorial.
--
sub version { print "I cuss your capitalist pig tendencies bad!"; }