in reply to Re: Hash Pipe Problem
in thread Hash Pipe Problem
#! perl -sw use strict; use threads; use IO::Select; $|++; my $sel = IO::Select->new(); my %children; for (1..2) { open my $fh, q[ perl -le'$|++; sleep(1), print qq[$$: $_] for 1 .. 10' | ] or die $!; $sel->add($fh); $children{$fh} = ""; } while (%children) { for my $fh ( $sel->can_read() ) { our $buf; local *buf = \( $children{$fh} ); # alias sysread($fh, $buf, 4096, length($buf)) or do { print("$buf\n") if length($buf); $sel->remove($fh); delete($children{$fh}); next; }; print $1 while $buf =~ s/^(.*\n)//; } }
Definitely more complex and less scalable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hash Pipe Problem
by BrowserUk (Patriarch) on Feb 26, 2009 at 20:41 UTC | |
by ikegami (Patriarch) on Feb 26, 2009 at 20:44 UTC |