sub credentials { my($self, $netloc, $realm, $uid, $pass) = @_; @{ $self->{'basic_authentication'}{lc($netloc)}{$realm} } = ($uid, $pass); } sub get_basic_credentials { my($self, $realm, $uri, $proxy) = @_; return if $proxy; my $host_port = lc($uri->host_port); if (exists $self->{'basic_authentication'}{$host_port}{$realm}) { return @{ $self->{'basic_authentication'}{$host_port}{$realm} }; } return (undef, undef); } #### package Nonce; use base 'WWW::Mechanize'; sub get_basic_credentials { my ( $self, $realm, $uri, $proxy ) = @_; my $netloc = lc $uri->host_port; local $| = 1; print "<$netloc>\n<$realm>\n"; return undef; } package main; my $M = Nonce->new(); $M->get('http://anywhere.com/mytest?rm=test', @args); # etc. #### use WWW::Mechanize; my $M = WWW::Mechanize->new(); $M->credentials( 'host:port', 'realm', 'user', 'password' ); # etc.