I tried to make a while loop with multiple threads by using Parallel::ForkManager.
It's a very easy module, which seems to work fine.
I only have one problem. When I run the script my cpu runs to 100% and it keeps on draining more memory.
I hope you perlmonks can fix this.
BTW, I run it with ActivePerl 5.10.
Thx in advance
use LWP::UserAgent; use HTTP::Request; use Parallel::ForkManager; $ua = new LWP::UserAgent; $ua->timeout(2); $ua->agent("Mozilla/6.0"); $pm = new Parallel::ForkManager(10); open(LIST,"lan.txt"); while (<LIST>) { $pm->start and next; chomp($_); $url = "http://".$_."/index.php"; $req = HTTP::Request->new('GET',$url); $res = $ua->request($req); $content= $res->content; if ($content =~ /ok/) { print $_."\n"; } $pm->finish; } $pm->wait_all_children; close(LIST); exit;
In reply to Parallel::ForkManager (high cpu and a lot of memory) by marto9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |