Silly question...

Why not use wget?

No need for a big perl script--assuming you're running *nix.

man wget

You can use it to imitate a browser, including login information and site cookies, while downloading files or webpages.

Example:

Code:
 wget -m -c --convert-links --user="Mister Man" --password=PreTTyPlease --load-cookies cookie.txt  --user-agent="Mozilla/4.0
...