Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: forking and monitoring processes

by zentara (Cardinal)
on Jan 08, 2005 at 12:30 UTC ( [id://420512]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://420512]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2025-06-22 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.