in reply to Hello All
I'd use LWP::UserAgent to make the request(s). You'll get a HTTP::Response object; call ->headers() on that and you'll end up with a HTTP::Headers object that you can query as needed.
Here's some skeleton code to get you started (<s>*completely* untested!</s> now marginally tested):
#!/usr/bin/perl use feature qw/say/; use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy(); open my $ips, "<", "ips.txt" or die "Cannot open ips.txt: $!"; while(<$ips>) { chomp; my $response = $ua->get("http://$_/"); unless($response->is_success) { warn "Failed to process $_: " . $response->status_line; next; } say "Headers for $_:"; my $headers = $response->headers(); foreach my $header ($headers->header_field_names()) { say "\t$header: " . $headers->header($header); } say ""; }
Processing the results in the desired fashion is left as an exercise for the reader.
|
|---|