Usually in this case WWW::Mechanize is recommended, which does the cookie handling very well. I have no idea how good the actual data extraction is, though.
Comment on Re: good CPAN modules for webscraping with GET, POST and cookies
Here is a description how WWW-Mechanize together with
WWW-Mechanize-Shell
can be used to record the interaction. This can serve as a first step in your automating task.