Alternative content
syntax: $output = open2(\*CHLD_OUT, \*CHLD_IN, 'command arg1 arg2');
It runs a process for both reading and writing and creates a pipe to both STDIN and STDOUT. It can be used in both ways:
$output = open2(my $out, my $in, 'command arg1 arg2');
OR without using the shell
$output = open2(my $out, my $in, 'command', 'arg1', 'arg2');
You can read about it more in the documentation: IPC::Open2.