小编May*_*yeu的帖子

在我循环使用相同的哈希时,在Perl中从哈希引用中删除密钥是否安全?为什么?

我基本上想要这样做:

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 hash key

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

简单的open3示例不起作用

我正在尝试制作一个主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 ipc ipcopen3

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

是否可以只在Perl中调用子程序调用?

我想知道是否有一个Perl分析器可以在特定子程序的子程序调用中分析时间.

我不想计时整个子程序(从调用到返回),而只是Perl花在调用子程序上的时间(在调用和子程序的第一条指令之间).

这可能吗 ?(当然,在我所有的90k代码行中添加时间功能不用:))

谢谢.

perl profiling subroutine

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

标签 统计

perl ×3

hash ×1

ipc ×1

ipcopen3 ×1

key ×1

profiling ×1

subroutine ×1