Hello alaa21a and welcome to the monastery and to the wonderful world of Perl!

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*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.