I am reading the perlcritic documentation to avoid backticks and use IPC::Open3 here:
http://perl-critic.stacka.to/pod/Perl/Critic/Policy/InputOutput/ProhibitBacktickOperators.html
I am trying to find the least 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 it complains with the following error:
Use of uninitialized value in <HANDLE> at ipc_open3.pl line 7
Any ideas?
EDITED: Ok, here is what I've got. Unless there is a way to simplify it, I'll stick to 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;