| IO-Mux documentation | view source | Contained in the IO-Mux distribution. |
IO::Mux::IPC - exchange data with external command
IO::Mux::IPC is a IO::Mux::Bundle is a IO::Mux::Handler::Read is a IO::Mux::Handler IO::Mux::Bundle also extends IO::Mux::Handler::Write is a IO::Mux::Handler::Write is a IO::Mux::Handler
my $mux = IO::Mux::Select->new; # or ::Poll
use IO::Mux::Open '|-|', '|=|';
my $pipe = $mux->open('|-|', $cmd, @cmdopts);
use IO::Mux::IPC;
my $ipc = IO::Mux::IPC->new(command => [$cmd, @cmdopts]);
$mux->add($ipc);
$pipe->getline(sub {print "$_[0]\n"});
With this handler, you set-up a two way communication between the current process and some other process. This is not easy to program: you may need to play with timeouts every once in a while.
This module is based on IO::Mux::Bundle, because it will use two or three pipes to facilitate the communication.
-Option --Defined in --Default command <required> errors <true> fh IO::Mux::Handler <required> mode |=| name IO::Mux::Handler '|$cmd|' read_size IO::Mux::Handler::Read 32768 stderr IO::Mux::Bundle <undef> stdin IO::Mux::Bundle <required> stdout IO::Mux::Bundle <required> write_size IO::Mux::Handler::Write 4096
The external command to be executed. Either the COMMAND needs to parameters, or you need to pass an ARRAY of the command name and all its parameters.
Include the stderr channel in the communication as well. These will be printed to STDERR by default.
|-| or |=|In the |-| mode, only STDIN and STDOUT are processed. Specifing
the |=| has the same effect as setting the errors option: open
a connection for STDERR as well.
Open the pipe to read. MODE is either |-| or |=|. When you
need to pass additional OPTIONS to the implied new(), then you must
use an ARRAY for command name and its optional parameters.
example:
my $mux = IO::Mux::Poll->new;
$mux->open('|-|', 'sort', '-u'); # no opts
$mux->open('|-|', ['sort', '-u'], %opts);
$mux->open('|-|', 'sort'); # no opts
$mux->open('|-|', ['sort'], %opts);
The process id of the child on the other side of the pipe.
The bits of the open mode.
This module is part of IO-Mux distribution version 0.11, built on January 26, 2011. Website: http://perl.overmeer.net/ All modules in this suite: Any::Daemon, IO::Mux, and IO::Mux::HTTP.
Please post questions or ideas to perl@overmeer.net
Copyrights 2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
| IO-Mux documentation | view source | Contained in the IO-Mux distribution. |