将 IPC::Run 与超时一起使用会导致 Modification of a read-only value 错误

Using IPC::Run with timeouts results in Modification of a read-only value error

我正在使用 IPC::Run 超时,我收到一个奇怪的错误: Modification of a read-only value attempted at ${HOME}/perl5/lib/perl5/IPC/Run.pm line 1693.

use strict;
use warnings;
use IPC::Run qw(timeout);
​
my $job_command = '/bin/ls';
my $timeout_value = 20;
my $t = timeout($timeout_value);
IPC::Run::run($job_command, undef, undef, undef, $t);

有人对此有经验吗?

编辑添加,这是使用 perl v5.16.3 和 v5.22.0 使用 IPC::Run 版本 20200505.0

的结果

undef 不是有效参数。

简单使用

IPC::Run::run($job_command, $t);

测试:

use IPC::Run qw( run timeout );

run([ 'perl', '-e', 'sleep' ], timeout(5));

输出:

IPC::Run: timeout on timer #1 at /home/ikegami/usr/perlbrew/perls/5.32.0t/lib/site_perl/5.32.0/IPC/Run.pm line 2951.