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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: forking and monitoring processes
by Anonymous Monk on Jan 09, 2005 at 20:57 UTC | |
by zentara (Cardinal) on Jan 10, 2005 at 12:10 UTC |