The code below was actually taken from a script I wrote that accessed an IIS server. It has been modified a bit, but should work:
#!/usr/bin/perl
use strict;
use LWP;
use LWP::UserAgent;
my $URI = 'https://www.domain.com/protected_realm';
my $user = 'foo';
my $pass = 'bar';
# define user agent
my $ua = LWP::UserAgent->new();
$ua->agent("USER/AGENT/IDENTIFICATION");
# make request
my $request = HTTP::Request->new(GET => $URI);
# authenticate
$request->authorization_basic($user, $pass);
# except response
my $response = $ua->request($request);
# get content of response
my $content = $response->content();
# do whatever you need to do with the content here
print $content;
exit;