hello all,
i am thinking of adding the ability to fork into a script i've written 
recently. the script acts on a list of nodes. currently it does this, one 
at a time, which could prove to be a lengthy process for longer lists.

i was thinking that fork would allow me to spawn child pids and speed up 
the process. i am reading from the camel book p167, however i'm a network 
guy that somehow got involved in writing perl, so my understanding of 
forks and processes is limited.

i'll skip putting in the whole of my code, but it can be summed up as:

for my $node(@devices) {

  ##subroutines

}

i'm not certain where i would fork to allow for X number of child 
processes to be started at once, or whether the 'for' statement would be 
rewritten. the example i am using to get familiar with fork is:

#!/usr/bin/perl -w

use strict;

my $i = "0"; my $pid;

while ($i < 5) {

  FORK: {
    if ($pid=fork) {
      next;

    } elsif (defined $pid) {
      print "hello\n";
      exit;

    } else {
      die "Cant fork! : $!\n";

    }

  }

  $i++;
}

print "The End\n";



i dont think that i am drawing the lines very well. i'm not grasping how 
fork can tie in with my existing code. any pointers are appreciated.

regards -c


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to