in reply to forking and monitoring processes

#!/usr/bin/perl use warnings; use strict; use Parallel::ForkManager; my @dirs = qw ( 1 2 3 4 5 6 7 8 9 ); my $max_tasks = 3; my $pm = new Parallel::ForkManager($max_tasks); $|++; my $start = time(); for my $dir (@dirs) { my $pid = $pm->start and next; printf "Begin $dir at %d secs.....\n", time() - $start; #do your processing here #push all the $dir/files into an array #and search through them line by line # # if( $line =~ /desktop/){ # print $filename,' -> ',$.,"\n"; # $pm->finish; # last; # } printf "done at %d secs!\n", time() - $start; $pm->finish; } print " all done\n";

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: forking and monitoring processes
by Anonymous Monk on Jan 09, 2005 at 20:57 UTC
    Hello,

    Thank you for the response. I understand that max_tasks will start in parallel from the @dirs array. What I was wondering was if there was a way in the "for" statement to read the output line by line. I was not sure how to do that. Would I need to use file handles? I was a little confused in that part.

    Thanks.

      Show us your code, and we will help you correct it.

      I'm not really a human, but I play one on earth. flash japh