Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Reading partial lines/strings from a pipe

by slightly72 (Initiate)
on Oct 10, 2007 at 18:24 UTC ( #644058=note: print w/ replies, xml ) Need Help??


in reply to Re: Reading partial lines/strings from a pipe
in thread Reading partial lines/strings from a pipe

Phil, thank you very much for the pointer and the book reference, it got me in the right direction.

The final solution is almost like the one you suggested:

my $buffer = ''; $rdr->blocking(0); while ($buffer eq '') { $rdr->read($buffer,1024); }

$rdr->read is just an OO wrapper for read.

The key to making this work was to use $rdr->blocking(0), which makes the pipe reading non-blocking. Otherwise a deadlock occurs -- maybe because the read command blocks while waiting for 1k to be filled, but not sure.

Thank you,
Tibi


Comment on Re^2: Reading partial lines/strings from a pipe
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://644058]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2015-07-04 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls