I picked the idea of zentara using Parallel::ForkManager and LWP::UserAgent, here ist what works for me:
#!/usr/bin/perl -w use strict; use warnings; use Parallel::ForkManager; use LWP::UserAgent ; my $refUrlList = []; my $maxChild = "3"; my $maxRedir = "5"; my $maxSize = "300"; my $timeout = "5"; (my $logFile = $0) =~ s/\.(\w+)$/\.log/; for ( @ARGV){ if ( -f ){ open ( IN, "<", $_) or die "Cant open $_: $!\n"; while (<IN>){ push(@$refUrlList, $_); } close ( IN) or die "Close Failed: $_: $!\n"; } } + + &multiUrl( $refUrlList); sub multiUrl { my $refUrls = shift; open ( OUT, ">> $logFile") or die "Can't open $logFile: $!\n"; my $pm = new Parallel::ForkManager( $maxChild); for ( @$refUrls) { chomp( my $url = $_); $pm->start and next; my $ua = LWP::UserAgent->new; $ua->agent( $0); $ua->max_redirect( $maxRedir); $ua->max_size($maxSize); $ua->timeout( $timeout); my $res = $ua->get( $url); print OUT "$url | " . $res->code . " | " . $res->message ."\n"; print "$url | " . $res->code . " | " . $res->message ."\n"; $pm->finish; } $pm->wait_all_childs; close ( OUT) or die "Close Failed: $logFile: $!\n"; }

In reply to Re: check multiple URLS in the same time by thonar
in thread check multiple URLS in the same time by sabri

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.