You want to use LWP to fetch web pages or submit forms, but the web server requires authentication.
Set the username and password for a particular realm with the user agent's credentials method:
$ua->credentials('http://www.perlcabal.com/cabal_only/', 'Secret Perl Cabal Files', 'username' => 'password');
To access pages protected by basic authentication, a browser must supply the username and password for the realm of the authentication. The realm is just a string that identifies which username and password the user must supply. The credentials method tells the user agent to send the username and password for a particular realm.
A somewhat kludgey solution is to specify URLs with the username and password in them:
This is kludgey because links within the returned document do not have your username and password encoded in them. Solutions that rely entirely on URL-encoded usernames and passwords often quickly degenerate into code that wishes it had used credentials to begin with.
The documentation for the CPAN module LWP::UserAgent