Perl IPC: Is Open3 Minimum to Pass Perlcritic?

I read perlcritic documentation to avoid backlinks and use IPC :: Open3 here:

http://perl-critic.stacka.to/pod/Perl/Critic/Policy/InputOutput/ProhibitBacktickOperators.html

I am trying to find the smallest verbose option that will work and satisfy perlcritic:

#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open3 'open3'; $SIG{CHLD} = 'IGNORE';
my $cmd = 'ls';
my ($w,$r,$e); open3($w,$r,$e,$cmd);
my @o = <$r>; my @e = <$e>;
1;

But he complains about the following error:

Use of uninitialized value in <HANDLE> at ipc_open3.pl line 7

Any ideas?

EDITED: Alright, that’s what I have. If there is a way to simplify it, I will stick with this:

#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open3 'open3'; $SIG{CHLD} = 'IGNORE';
use Symbol 'gensym';
my $cmd = 'ls';
my ($w,$r,$e) = (undef,undef,gensym); my $p = open3($w,$r,$e,$cmd);
my @o = <$r>; my @e = <$e>;
1;
+3
source share
2 answers

The error parameter IPC::Open3::open3must not be undefined. The syntax forIPC::Open3 uses a function Symbol::gensymto pre-initialize the error argument:

my($wtr, $rdr, $err);
use Symbol 'gensym';
$err = gensym;
$pid = open3($wtr, $rdr, $err, 'some cmd and args', 'optarg', ...);

, undef.

, perlcritic

my @o = `ls 2>/dev/null`   ## no critic
+7

. IPC:: Open3 - , . , , (), STDERR.

IPC:: Run3 IPC:: Run .

:

run3 $cmd, undef, \my $out, \my $err;
run3 [ $prog, @args ], undef, \my $out, \my $err;
run3 [ $prog, @args ], undef, \my @out, \my @err;
+8

All Articles