相关疑难解决方法(0)

线程共享perl

我写了一个代码,我需要让它多线程.Evething工作,但每个循环重复4次:

use LWP::UserAgent;
use HTTP::Cookies;
use threads;
use threads::shared;

$| = 1;

$threads = 4;
my @groups :shared = loadf('groups.txt');

my @thread_list = ();
$thread_list[$_] = threads->create(\&thread) for 0 .. $threads - 1;
$_->join for @thread_list;
thread();

sub thread
{
    my $url = 'http://www.site.ru/';
    my $response = $web->post($url, Content =>
                    ['st.redirect' => ''
                    ]);
    foreach $i (@groups)
    {

        my $response  = $web->get($i);
        if(!($response->header('Location')))
        {
            ---------;
        }
        else
        {
            ----------;
        }

    }

}

sub loadf {
    open (F, "<".$_[0]) or erroropen($_[0]); …
Run Code Online (Sandbox Code Playgroud)

perl multithreading

1
推荐指数
1
解决办法
195
查看次数

标签 统计

multithreading ×1

perl ×1