Re: Reading from multiple pipes

2009-09-30 Thread Ed Avis
Ed Avis waniasset.com> writes: >I'd like to fork several child processes and read lines from each It appears that IO::BufferedSelect does what I want! From its documentation: use IO::BufferedSelect; my $bs = new BufferedSelect($fh1, $fh2); while(1) { my @ready = $bs->re

Re: Reading from multiple pipes

2009-09-30 Thread Ed Avis
Ed Avis waniasset.com> writes: >I'd like to fork several child processes and read lines from each, There is IO::Select which provides a convenient way to see which filehandles have data for reading. But there is no guarantee that the data available will form a complete line. I am looking for s

Reading from multiple pipes

2009-09-30 Thread Ed Avis
I'd like to fork several child processes and read lines from each, for example: open my $fh_foo, '-|', 'yes', 'foo' or die $!; open my $fh_bar, '-|', 'yes', 'bar' or die $!; while (<$fh_foo> OR <$fh_bar>) { # magic happens here say "got a line from one of them: $_