# ALWAYS use the below two lines!! use strict; use warnings; # ALWAYS use the above two lines!! use LWP::Protocol::https; use LWP::UserAgent; # also use the 3 form open and check for failures: my $ip_file = '/path/to/file.ext'; # use lexical filehandles # UPDATE ooops.. missed a comma.. see hippo below http://www.perlmonks.org/?node_id=1202382 open $ip_fh, '<', $ip_file or die "Unable to open $ip_file for reading!"; my $ua = LWP::UserAgent->new; while (<$ip_fh>){ # remeber to chomp lines arriving chomp; # get every IP my @ip = split /\s+/,$_; # process them foreach my $ip(@ip){ # construct the request for HTTP protocol my $httpr = $ua->get('http://'.$ip); # note that you just need title not the whole GET print "http://$ip\t\t",$httpr->status_line,"\t\t",$httpr->title,"\n"; # do the same for HTTPS protocol my $httpsr = $ua->get('https://'.$ip); print "https://$ip\t\t",$httpsr->status_line,"\t\t",$httpsr->title,"\n"; } } # sample output http://216.58.198.36 200 OK Google https://216.58.198.36 500 Can't connect to 216.58.198.36:443 http://66.39.54.27 200 OK PerlMonks - The Monastery Gates https://66.39.54.27 500 Can't connect to 66.39.54.27:443