我有这样的结构(散列哈希):
%hash=(
Level1_1=> {
Level2_1 => "val1",
Level2_2=> {
Level3_1 => "val2",
Level3_2 => "val1",
Level3_3 => "val3",
},
Level2_3 => "val3",
},
Level1_2=> {
Level2_1 => "val1",
Level2_2=> {
Level3_1 => "val1",
Level3_2 => "val2",
Level3_3 => "val3",
},
Level2_3 => "val3",
},
Level1_3=> {
Level2_1 => "val1",
Level2_2 => "val2",
Level2_3 => "val3",
});
Run Code Online (Sandbox Code Playgroud)
我想grep这个由"val2"过滤的嵌套结构,输出应该是:
%result=(
Level1_1=> { Level2_2=> { Level3_1 => "val2"} },
Level1_2=> { Level2_2=> { Level3_2 => "val2" } },
Level1_3=> { Level2_2 => "val2" …Run Code Online (Sandbox Code Playgroud) 我试图使用Parallel :: ForkManager来运行并行,但遗憾的是子例程并行不返回任何条目.
sub parallel {
my ($self,$values) = @_;
my %hash;
my $pm = Parallel::ForkManager->new(200);
foreach my $IP ( keys %{$values} ) {
my $pid = $pm->start and next;
$hash{$IP}=$self->getData($IP);
$pm->finish(0, \$hash{$IP});
}
$pm->wait_all_children;
return %hash;
}
print Dumper( parallel(%data) );
Run Code Online (Sandbox Code Playgroud)
我做错了什么?有任何想法吗?
我使用以下配置从本地127.0.0.1:2000代理访问Internet。
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
#debug
#quiet
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen appname 0.0.0.0:2000
mode http
stats enable
acl white_list src 127.0.0.1
tcp-request content accept if white_list
tcp-request content reject
stats uri /haproxy?stats
stats realm Strictly\ Private
stats auth special_admin:special_username
balance roundrobin
option httpclose
option forwardfor …Run Code Online (Sandbox Code Playgroud) 我需要转换以下整数数字
29900
17940
1
Run Code Online (Sandbox Code Playgroud)
以十进制格式表示
299.00
179.40
0.01
Run Code Online (Sandbox Code Playgroud)
我已经尝试过Data/Types.pm但是to_decimal(1,2)返回1.00
是否有任何限制并行运行线程的选项.在示例中,我有以下代码:
use threads;
use LWP::UserAgent qw( );
my $ua = LWP::UserAgent->new();
my @threads;
# if @threads < 200
for my $url (@URL_LIST) {
push @threads, async { $ua->get($url) };
}
# if @threads <= 200
for my $thread (@threads) {
my $response = $thread->join;
...
}
Run Code Online (Sandbox Code Playgroud)
如果@URL_LIST包含超过10000个网址,我正在尝试创建脚本以仅执行200个并行请求!但不幸的是,脚本最终得到的信息是20多个线程未完成.任何想法解决方案应该是什么?