我基本上想要这样做:
foreach my $key (keys $hash_ref) {
Do stuff with my $key and $hash_ref
# Delete the key from the hash
delete $hash_ref->{$key};
}
Run Code Online (Sandbox Code Playgroud)
安全吗?为什么?
我正在尝试制作一个主perl脚本,调用子perl脚本并通过管道进行交互.
我为master写了这段代码:
#!/usr/bin/env perl
use strict;
use warnings;
use IPC::Open3;
my @children;
for my $i ( 0 .. 4 ) {
print "Master: " . $i . ", I summon you\n";
$children[$i] = {};
$children[$i]->{'pid'} = open3( my $CH_IN, my $CH_OUT, my $CH_ERR, 'perl child.pl -i ' . $i );
$children[$i]->{'_STDIN'} = $CH_IN;
$children[$i]->{'_STDOUT'} = $CH_OUT;
$children[$i]->{'_STDERR'} = $CH_ERR;
my $line = readline $children[$i]->{'_STDOUT'};
print $line ;
}
print "Master: Go fetch me the sacred crown\n";
for my $i ( …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一个Perl分析器可以在特定子程序的子程序调用中分析时间.
我不想计时整个子程序(从调用到返回),而只是Perl花在调用子程序上的时间(在调用和子程序的第一条指令之间).
这可能吗 ?(当然,在我所有的90k代码行中添加时间功能不用:))
谢谢.