Have ye considered the wonders that WW::Mechanize would do for your coding? It's a module to simulate a browser for purposes of interacting on a website. With the help of HTTP::Recorder, you can even do it once manually, and have the module build the WWW:Mechanize script you need for your apps.
Based upon what you've written, I'd strongly consider those options, and doing some research upon them. The docs I've linked to above, plus Googling for the module names, will lead to a wealth of resources.
Think that might help remove a layer or two of work and code for you?
----Asim, known to some as Woodrow.