Pardon my ignorance, but I have trouble understand the docs of IPC::run3

How do I implement the following, including catching stdout and stderr with run3?

the docs claim

I'm confused, is it even possible to have a bidirectional communication between two simultaneously running processes with run3?

If not what's the appropriate solution?

client.pl
use v5.12; use warnings; use IPC::Run3; my ($cmd, $in, $out, $err); $cmd = 'perl ./server.pl'; open my $fh_in,"|-", $cmd; #my @in; #run3($cmd, \@in); sub out { $fh_in->say(@_); } my $doit; for my $try (2,3,2) { $doit = "$;" x $try; out($doit); out($_) for 1..$try; out($doit); } out("EOF");

server.pl
use v5.12; use warnings; STDOUT->autoflush; my $doit; my $input; while ( my $line = <STDIN> ) { unless ( defined $doit ){ $doit = $line; last if $doit eq "EOF"; next; } if ($line eq "$doit") { doit(); undef $doit; } else { $input .= $line; } } say "exit by $doit"; exit; sub doit { print "((( STDOUT ::: $doit"; print $input; print "))) STDOUT ::: $doit"; #warn "STDERR:",$input," "; $input =""; }

output
((( STDOUT :::  1 2 ))) STDOUT :::  ((( STDOUT :::  1 2 3 ))) STDOUT :::  ((( STDOUT :::  1 2 ))) STDOUT :::  exit by EOF

update

found this

Bidirectional Communication with Another Process

doesn't seem to be overly portable and I doubt run3 is the solution...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Concurrency with IPC::Run3 ? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.