use LWP::Simple;
use Parallel::ForkManager;
...
@links=(
["http://www.foo.bar/rulez.data","rulez_data.txt"],
["http://new.host/more_data.doc","more_data.doc"],
...
);
...
# 同时使用 30 个进程
my $pm = new Parallel::ForkManager(30);
foreach my $linkarray (@links) {
$pm->start and next; # 开始 fork
my ($link,$fn) = @$linkarray;
warn "Cannot get $fn from $link"
if getstore($link,$fn) != RC_OK;
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;