use WWW::Mechanize; my $M = WWW::Mechanize->new(); $M->credentials( 'host:port', 'realm', 'user', 'password' ); # etc.