IOMux::IPC - exchange data with external command
IOMux::IPC is a IOMux::Bundle is a IOMux::Handler::Read is a IOMux::Handler IOMux::Bundle also extends IOMux::Handler::Write is a IOMux::Handler::Write is a IOMux::Handler
my $mux = IOMux::Select->new; # or ::Poll use IOMux::Open '|-|', '|=|'; my $pipe = $mux->open('|-|', $cmd, @cmdopts); use IOMux::IPC; my $ipc = IOMux::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 IOMux::Bundle, because it will use two or three pipes to facilitate the communication.
Extends "DESCRIPTION" in IOMux::Bundle.
Extends "METHODS" in IOMux::Bundle.
Extends "Constructors" in IOMux::Bundle.
-Option --Defined in --Default command <required> errors <true> fh IOMux::Handler <required> mode |=| name IOMux::Handler '|$cmd|' read_size IOMux::Handler::Read 32768 stderr IOMux::Bundle <undef> stdin IOMux::Bundle <required> stdout IOMux::Bundle <required> write_size IOMux::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.
|-|
|=|
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.
errors
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 = IOMux::Poll->new; $mux->open('|-|', 'sort', '-u'); # no opts $mux->open('|-|', ['sort', '-u'], %opts); $mux->open('|-|', 'sort'); # no opts $mux->open('|-|', ['sort'], %opts);
Extends "Accessors" in IOMux::Bundle.
The process id of the child on the other side of the pipe.
Inherited, see "Accessors" in IOMux::Bundle
Inherited, see "Accessors" in IOMux::Handler
The bits of the open mode.
Inherited, see "Accessors" in IOMux::Handler::Read
Inherited, see "Accessors" in IOMux::Handler::Write
Extends "User interface" in IOMux::Bundle.
Extends "Multiplexer" in IOMux::Bundle.
Extends "Helpers" in IOMux::Bundle.
Inherited, see "Helpers" in IOMux::Handler
This module is part of IOMux distribution version 1.00, built on November 11, 2015. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IOMux", and "IOMux::HTTP".
Please post questions or ideas to perl@overmeer.net
Copyrights 2011-2015 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
To install IOMux, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IOMux
CPAN shell
perl -MCPAN -e shell install IOMux
For more information on module installation, please visit the detailed CPAN module installation guide.