in reply to Pipes: Why does this fail?
use strict; use warnings; use IO::File; my $pipe = "/tmp/mypipe"; system('mkfifo', '--', $pipe) if !-p $pipe; open(my $to_child, '|-', "cat > ".text_to_shell_lit($pipe)) or die "Can't open create process 1: $!"; $to_child->autoflush(1); open(my $fr_child, '|-', "cat < ".text_to_shell_lit($pipe)) or die "Can't open create process 2: $!"; my $input = '12345678901234567890123456789012345678901234567890'; print($to_child $input); close($to_child); while (<$fr_child>) { print; }
Note that adding the close solves your problem, since it signals eof to the first cat, which causes it to close its output pipe, which signals eof to the second cat, which causes it to close its output pipe, which signals eof to your <>, which causes it to return.
I hope that cat is only used as an example!
|
|---|