IOMux::Pipe::Read - read from an external command
IOMux::Pipe::Read is a IOMux::Handler::Read is a IOMux::Handler
my $mux = IOMux::Select->new; # or ::Poll use IOMux::Open '-|'; my $pipe = $mux->open('-|', $command, @cmd_options); use IOMux::Pipe::Read; my $pipe = IOMux::Pipe::Read->new ( command => [$command, @cmd_options] ); $mux->add($pipe); $pipe->getline(sub {print "$_[0]\n"});
In an event driven program, reading is harder to use than writing: the read will very probably be stalled until data has arrived, so you will need a callback to handle the resulting data.
Creates a pipe, but does not start a process (yet). Used by IOMux::IPC, which needs three pipes for one process. Returned is not only a new pipe object, but also a write handle to be connected to the other side.
All OPTIONS which are available to IOMux::Handler::Read::new() can be used here as well.
-Option --Default read_size 4096
example:
my ($out, $out_rh) = IOMux::Pipe::Read->bare(name => 'stdout');
-Option --Defined in --Default command <required> fh IOMux::Handler <required> name IOMux::Handler '$cmd|' read_size IOMux::Handler::Read 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.
Open the pipe to read. MODE is always -|. When you need to pass additional OPTIONS to the implied new(), then you must use an ARRAY for command name and its optional parameters.
-|
my $mux = IOMux::Poll->new; $mux->open('-|', 'who', '-H'); # no opts $mux->open('-|', ['who', '-H'], %opts); $mux->open('-|', 'who'); # no opts $mux->open('-|', ['who'], %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 IOMux distribution version 0.12, built on January 27, 2011. 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 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.