#!/usr/bin/perl use LWP::UserAgent; use threads; use threads::shared; our $totalCount :shared; $totalCount = 1; $count = 1; $k=1; $thrCount = 5; $timeout = 5; $start = localtime(); for($i=0; $i<=$#ARGV; $i++) { if($ARGV[$i] eq "\-t"){ $thrCount = $ARGV[$i+1]; } elsif($ARGV[$i] eq "\-i") { $infile = $ARGV[$i+ 1]; } } open(CONTENTS, "<$infile) or die("Could not open file!"); while($input = ) { chomp $input; print "trying..... " . $input . "\n"; print " Total Count: " . $totalCount . " Count: " . $count . "\n"; $thr = threads->new(\&tryHTTP,$input); $thr->detach(); $count++; $k++; if($k % $thrCount == 0) { sleep($timeout); $k=1; } } close(CONTENTS); $end = localtime(); print $start . "\n"; print $end . "\n"; print $totalCount . "/ " . $count . "\n"; sub tryHTTP { $ua = LWP::UserAgent->new; $ua->timeout((10)); $url = "http://www." . $_[0] . ".com"; $response = $ua->get($url); if($response->is_success) { $totalCount++; $response = ""; } }