in reply to Re^2: Stop fork in Parallel::ForkManager
in thread Stop fork in Parallel::ForkManager
You answered my question perfectly (I confess I'm new to the IPC game; actually I started reading that part of the Llama today). Good links. :)
In regards to the original question...I found this code on wikipedia, and it seems to do what you want(?).
#!/usr/bin/perl $pid = fork(); #Declare fork if ($pid == 0) { #Jump into the Child process for ($j = 0; $j < 10; $j++) { print "child: $j\n"; sleep 1; } exit(0); #Exit the fork [child process] } elsif ($pid > 0) { for ($i = 0; $i < 10; $i++) { print "parent: $i\n"; sleep 1; } exit(0); #Exit parent }
So the thing here is to test the pid. In your code, you would say:
$pm->finish if ($pid == 0 && $content =~ m/string/); #...no match, do more work... $pm->finish;
Or am I totally missing the boat here (likely)? :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Stop fork in Parallel::ForkManager
by casimo (Sexton) on Sep 27, 2009 at 23:50 UTC | |
|
Re^4: Stop fork in Parallel::ForkManager
by casimo (Sexton) on Sep 28, 2009 at 16:33 UTC | |
|
Re^4: Stop fork in Parallel::ForkManager
by sierpinski (Chaplain) on Sep 30, 2009 at 12:26 UTC | |
by Anonymous Monk on Sep 30, 2009 at 14:05 UTC |