in reply to Download file over HTTP

You set the username and password for basic authentication on the user agent.
$ua->credentials($host, $realm, $user, $pass);
The mirror method downloads the file without storing the response in memory. Using content on the response puts the whole file in memory which can be a problem with big files.
$ua->mirror($url, $file);