WWW::Webrobot::Forker - fork children and open socket to childrens STDOUT
sub exec_child { my ($child_id) = @_; print "Childs $child_id answer\n"; } sub readline { my ($child_id, $line) = @_; print ">> $line\n"; } my $forker = Forker -> new(); $forker -> fork_children(1, \&exec_child); $forker -> eventloop(\&readline);
This module is used to fork off some worker processes.
Construct an object.
Forks off $count children. Each child executes \&function, then it terminates. STDOUT will be sent to the parent.
child_function takes the following parameters:
my ($child_id) = @_;
Start the eventloop. Any data that is sent from a child via STDOUT will be forwarded to \&readline on a line by line basis. This method returns when all children closed STDOUT.
Readline takes the following parameters:
my ($child_id, $line) = @_;
Note 1: $child_id of readline() is not the same as $child_id of child_function()
$child_id
readline()
child_function()
Note 2: Currently no way is provided for the parent to send data to the child.
To install WWW::Webrobot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Webrobot
CPAN shell
perl -MCPAN -e shell install WWW::Webrobot
For more information on module installation, please visit the detailed CPAN module installation guide.