No problem w/ the script:

/opt/perl5/bin/perl ./scr.pl
Result was Hello there


> On Apr 9, 2018, at 2:14 PM, Daniel Ruggeri <drugg...@primary.net> wrote:
> 
> use strict;
> use IPC::Open3;
> use Symbol;
> 
> my $results = run_and_gather_output("echo 'Hello there'");
> print "Result was " . join("", @{$results->{stdout}}) . "\n";
> 
> sub run_and_gather_output {
>    my $command = shift;
>    my ($cin, $cout, $cerr);
>    $cerr = gensym();
>    my $pid = open3($cin, $cout, $cerr, $command);
>    waitpid( $pid, 0 );
>    my $status = $? >> 8;
>    my @cstdout = <$cout>;
>    my @cstderr = <$cerr>;
>    return { status => $status, stdout => \@cstdout, stderr => \@cstderr };
> }

Reply via email to