123456789101112
#!/usr/bin/perluse strict;use warnings;use LWP::UserAgent;my $ua = LWP::UserAgent->new();my $req = HTTP::Request->new('GET', $ARGV[0]);my $res = $ua->simple_request($req);if($res->code == 401 && $res->header('WWW-Authenticate') =~ m/realm="([^"]+)"/) { print "Realm: " . $1;}