Yes, I changed a little, because I'm looking for a working code.
Here is a new code where Google returns a different code.
use strict;
use warnings;
use LWP::UserAgent;
my @hostnames = (
'http://google.com',
'https://google.com',
'http://microsoft.com',
'https://microsoft.com',
'http://bing.com',
'https://bing.com',
);
my $ua = LWP::UserAgent->new;
for my $host (@hostnames) {
my $res = $ua->get ($host);
print $res->code . ' => ' . $res->status_line . "\n";
}
print "LWP: $LWP::VERSION\n";
print "IO::Socket::SSL: $IO::Socket::SSL::VERSION\n";
It returns:
200 => 200 OK
500 => 500 Can't connect to google.com:443 (connect: Network is unreac
+hable)
500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is
+ unreachable)
500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is
+ unreachable)
200 => 200 OK
200 => 200 OK
LWP: 5.833
IO::Socket::SSL: 1.31