I didn't test this so don't assume it will work, but I think it should ;-)
eof should return true if there is nothing left to read. So, instead of
using <> which will block until there's something to read (or the fh is
closed), you could periodically test eof on your file handles. Perhaps
something like:
sub eof_and_read {
if (eof ($_[0])) {
return '';
} else {
return <$_[0]>;
}
}
Simply replacing while (<blah>) with while (eof_and_read(blah)) won't
work too well though; you'd have to check if the file is open. The way
to do that (that I have found) is to tell, which will return -1 if the
fh doesn't really exist or is closed. (I recommend adapting this to
avoid warnings where you know there will be warnings, such as tell
($fakefh).)
e.g.,
sub isopen {
no warnings; # tell() on unopened filehandle
return tell (shift) > -1;
}
I ended up using IO::Select to process the open3 read and error handles
at the same time and in order (pretty much anyway) but still have them
in seperate handles :)
Thanks for your input!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>