Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Weirdness with IO::Select and IPC::Open3

by rastoboy (Monk)
on Mar 21, 2011 at 04:35 UTC ( [id://894404]=note: print w/replies, xml ) Need Help??


in reply to Re: Weirdness with IO::Select and IPC::Open3
in thread Weirdness with IO::Select and IPC::Open3

Hi ikegami, thanks for all the great responses. It's going to take me a while to study it all, but I was wondering--how would you do it without IO::Select? You seem to be suggesting it is less than ideal for the purpose, but all I know is when I google the errors I get when I don't use it, everyone says to use it :-).

Color me confused.

Replies are listed 'Best First'.
Re^3: Weirdness with IO::Select and IPC::Open3
by ikegami (Patriarch) on Mar 21, 2011 at 04:40 UTC

    If you don't care about the child's STDERR, you can send it to the parent's STDERR (using '>STDERR' for open3's third arg). Then, all you need is

    ... while (<$stdout_fh>) { chomp; if (/Have a nice day!\z/) { print("$query\n"); } elsif ($answers{$query}) { print($stdin_fh "$answers{$query}\n"); } else { # ...[ Do something with unrecognised output from STDIN. ]... } }

    You can do this because you have a strict request-response protocol.

    If you had a more asynchronous protocol, you still have lots of simpler options than select. These include IPC::Run, Expect and threads.

    when I google the errors I get when I don't use it, everyone says to use it :-).

    What errors would that be?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2024-03-28 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found