So your post go unanswered.. why? it seems to me because it appears like Frankenstein code, build up cutting and pasting other's code..
So, ok we approach Halloween, but Frankestein posts are not so much welcome here.. ;=)
But since is your first post..
I say this not to blast you down but to help you to learn better and ask better questions in the future: see How (Not) To Ask A Question for more details on how to ask something in a better way.
First of all use strict; use warnings lines are missing from your code and part of it does not compile with them in force.
Other parts will compile with use strict; use warnings and this let me to suppose you are cutting and pasting code.
In adition always use the 3 arg form of open and even better use another variable for the filename and use lexical filhandle: infact your open(OUTPUT,">>$save") is considered sumerian nowadays..
Take your free (yes; free!!) copy of the wonderful book by chromatic Modern Perl and read it.
Now about your goal: before going to parallelize the HTTP(S) requests using Parallel::ForkManager start with something simpler like my code below. In addittion LWP::UserAgent is not thread safe and this is the rationale for LWP::Parallel and LWP::Parallel::UserAgent existence.
So you want check an IP list for both HTTP and HTTPS connections? an get titles? As side note are you aware that an IP can have multiple websites configured on it to resposnd to an HTTP request (https sites are different)? you also know that a domain name can, by other hand, resolve multiple IPs?
# 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->ti +tle,"\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 Monast +ery Gates https://66.39.54.27 500 Can't connect to 66.39.54.27:443
PS ..oops missed a comma in the filehandle opening: see hippo below
L*
In reply to Re: Get Title ip's list browser -- suggestions for a newcomer
by Discipulus
in thread Get Title ip's list browser
by alaa21a
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |