#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; { #Create a new package that subclasses LWP::UserAgent. # we do this to allow overriding of the get_basic_credentials() method. package RequestAgent; our @ISA = qw(LWP::UserAgent); # All other subs would come from LWP::UserAgent. sub get_basic_credentials { #we only return the password for one location, so no magic necessary return ("user", "password"); } } my $ua = RequestAgent->new(); my $response = $ua->get("http://host:port/location"); die "Error while getting ", $response->request->uri, " -- ", $response->status_line, "\nAborting" unless $response->is_success; print $response->content, "\n";