| IO-Mux documentation | view source | Contained in the IO-Mux distribution. |
IO::Mux::Pipe::Write - write to an external command
IO::Mux::Pipe::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('|-', $command, @cmd_options);
use IO::Mux::Pipe::Write;
my $pipe = IO::Mux::Pipe::Write->new
(command => [$command, @cmd_options]);
$mux->add($pipe);
$pipe->write($text);
$pipe->print($text);
write $pipe $text;
print $pipe $text;
In an event driven program, you must be careful with every Operation System call, because it can block the event mechanism, hence the program as a whole. Often you can be lazy with writes, because its communication buffers are usually working quite asynchronous... but not always. You may skip the callbacks for small writes and prints.
Creates a pipe, but does not start a process (yet). Used by IO::Mux::IPC, which needs three pipes for one process. Returned is not only a new pipe object, but also a read handle to be connected to the other side.
All OPTIONS which are available to IO::Mux::Handler::Write::new() can be used here as well.
-Option --Default read_size 4096
example:
my ($in, $in_rh)
= IO::Mux::Pipe::Write->bare(name => 'stdin');
-Option --Defined in --Default command <required> fh IO::Mux::Handler <required> name IO::Mux::Handler '|$cmd' 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.
Open the pipe to write. 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.
example:
my $mux = IO::Mux::Poll->new;
$mux->open('|-', 'lpr', '-#4'); # no opts
$mux->open('|-', ['lpr', '-#4'], %opts);
$mux->open('|-', 'lpr'); # no opts
$mux->open('|-', ['lpr'], %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. |