With LWP::UserAgent, you can specify a "cookie jar" file by doing the following:
# Assumes $ua is an LWP::UserAgent object
use HTTP::Cookies;
my $cookie_jar = HTTP::Cookies->new(
file => "./lwp_cookies.dat",
autosave => 1,
);
$ua->cookie_jar($cookie_jar);
You can then use the $cookie_jar->add_cookie_header() method to potentially pre-load the cookie jar with the value. You may also be able to do so instead by using the additional arguments of the $lwp->get() method, similar to the following (untested):
$ua->get( $url, ':content_file' => 'file.bin', 'Cookie' => '...', );
Hope that helps.