My problem seems to be that I'm behind a firewall...
And the point of this script, is to GET a page first (to get
the cookie). Then fill in a form, then get the HTML
of the page which I get after filling in the form.

My problem lies in the fact that I need a "referer" from
the first page, which the normal UserAgent doesn't handle.

So how can I "fake" a referer?

This is part of my script:

#create the user agent
$ua = LWP::UserAgent->new;

#create a cookie jar and say where the cookie goes
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt",
autosave => 1));
$ua->agent("$0/0.1 " . $ua->agent);

#for my script I get the page first so I get the cookie
$req = HTTP::Request->new(GET => $SITE');
$req->header('Accept' => 'text/html');

# send request
$res = $ua->request($req);

#if we got the first page, we try to fill in the form.
if ($res->is_success) {
my $req = POST '$SITE',
[ username => 'user', password => 'pass', ];
$postres = $ua->request($req);
if ($postres->is_success) {
print "$postres->content;n";
} else {
print "Error in posting: " .$postres->statusline . "n";
} else { print "Error in getting webpage: " . $res->statusline . "n";