if ($opt_proxy) { my $h = "Proxy_Authorization"; my $req = new HTTP::Request; $req->proxy_authorization_basic($user, $passwd); $WWW::Mechanize::headers{$h} = $req->header($h); } # Then the rest of your program