The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

 Proc::Parallel - run multiple commands and process their output in parallel

SYNOPSIS

 use Proc::Parallel;

 startcommand($command, $per_line_callback, $at_eof_callback);

 finish_commands();

DESCRIPTION

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.

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().

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.

EXAMPLE

 startcommand($command, sub { 
        my ($handler, $ioe, $input_buffer_reference) = @_;
        while (<$ioe>) {
                # do suff for each line
        }
 });

 finish_commands();

LICENSE

This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.