#!/usr/bin/perl use strict; use warnings; use LWP::Simple; DOMAIN: while (my $domain = ) { chomp($domain); for my $protocol (qw/http https/) { next DOMAIN if test_url("$protocol://$domain"); for my $sub (qw/www web/) { next DOMAIN if test_url("$protocol://$sub.$domain"); } } print "Couldn't get anything from $domain\n"; } sub test_url { my $url = shift; print "Trying $url ..."; my $ua = LWP::UserAgent->new( timeout => 5, agent => 'Mozilla/5.0', ssl_opts => { verify_hostname => 0 }, ); my $response = $ua->get($url); if ($response->is_success) { print "OK\n"; return 1; } else { print "FAILED because " . $response->status_line . "\n"; return undef; } } __DATA__ google.com apple.com fred.com dschjksdbckjqh.com #### Trying http://google.com ...OK Trying http://apple.com ...OK Trying http://fred.com ...OK Trying http://dschjksdbckjqh.com ...FAILED because 500 Can't connect to dschjksdbckjqh.com:80 (Bad hostname 'dschjksdbckjqh.com') Trying http://www.dschjksdbckjqh.com ...FAILED because 500 Can't connect to www.dschjksdbckjqh.com:80 (Bad hostname 'www.dschjksdbckjqh.com') Trying http://web.dschjksdbckjqh.com ...FAILED because 500 Can't connect to web.dschjksdbckjqh.com:80 (Bad hostname 'web.dschjksdbckjqh.com') Trying https://dschjksdbckjqh.com ...FAILED because 500 Can't connect to dschjksdbckjqh.com:443 (getaddrinfo: nodename nor servname provided, or not known) Trying https://www.dschjksdbckjqh.com ...FAILED because 500 Can't connect to www.dschjksdbckjqh.com:443 (getaddrinfo: nodename nor servname provided, or not known) Trying https://web.dschjksdbckjqh.com ...FAILED because 500 Can't connect to web.dschjksdbckjqh.com:443 (getaddrinfo: nodename nor servname provided, or not known) Couldn't get anything from dschjksdbckjqh.com