use IO::Handle;
print "before the pipe\n";
sub getpipe {
my $hash2 = shift;
$hash2->{pid} = open( $hash2->{stdout}, "c:\\perl\\bin\\perl.exe yes.pl |") or die;
$hash2->{buffer} = "";
$hash2->{stdout}->blocking(0);
sleep( 3 );
return $hash2->{pid};
}
my $hash = {};
getpipe($hash);
my $fh = $hash->{stdout};
print( "pipe created\n" );
while( <$fh> ) {
print "got from pipe: $_";
sleep( 1 );
}
print( "done\n" );
####
while( 1 ) {
printf "%s yes\n", time();
sleep( 1 );
}
##
##
got from pipe: 1226094472 yes
1226094473 yes
1226094474 yes
1226094475 yes
1226094476 yes
1226094477 yes
1226094478 yes
1226094479 yes
1226094480 yes
1226094481 yes
1226094482 yes
1226094483 yes
1226094484 yes
1226094485 yes
1226094486 yes
1226094487 yes