Proc::Parallel - run multiple commands and process their output in parallel
use Proc::Parallel; startcommand($command, $per_line_callback, $at_eof_callback); finish_commands();
This module is a wrapper around an asynchronous IO library. It provides an easy interface for starting a bunch of commands and processing each line of output from those commands.
It uses IO::Event::Callback.
When the last of the commands finish, Event::unloop_all() is called so this module is not safe to use with other Event-based code.
Event::unloop_all()
The commands are started as you call startcommand(), but no output will be processed unless you call IO::Event::loop() or let finish_commands() call it for you. The call to finish_commands() or IO::Event::loop() returns when all the commands have completed. Additional commands may be started after calling finish_commands().
startcommand()
IO::Event::loop()
finish_commands()
In addition to the command to run, the startcommand() function takes two IO::Event-style callbacks: one that's called for each line of output and one that's called when at end-of-file.
startcommand($command, sub { my ($handler, $ioe, $input_buffer_reference) = @_; while (<$ioe>) { # do suff for each line } }); finish_commands();
This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.
To install Proc::Parallel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::Parallel
CPAN shell
perl -MCPAN -e shell install Proc::Parallel
For more information on module installation, please visit the detailed CPAN module installation guide.