Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Thanks a lot! - cartmanofvan#!/usr/bin/perl @dirname; $dirname[0]="TestList1.log"; $dirname[1]="TestList2.log"; $dirname[2]="TestList3.log"; for(1..4) { my $pid = fork(); if ($pid) { # parent push(@childs, $pid); print "we are in the parent bus \n"; waitpid($pid,0); } elsif ($pid == 0) { # child # here I want to read a different file each child # so child 1 would read dirname[0] # so child 2 would read dirname[1] # so child 3 would read dirname[2] # and they would all do the same thing, # but on different files # something like: #$mm = @child array's element number open (filelist, @dirname[$mm]) || die "couldn't open the file!"; @filename; @filename = <filelist>; print "@filename \n"; sleep 5; exit(0); } else { die "couldn’t fork: $! \n"; } print "LAST IN FOR \n"; } print "AFTER FOR \n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fork : distinguish between different child?
by keszler (Priest) on Oct 24, 2011 at 23:49 UTC | |
|
Re: fork : distinguish between different child?
by ikegami (Patriarch) on Oct 24, 2011 at 23:56 UTC | |
|
Re: fork : distinguish between different child?
by JavaFan (Canon) on Oct 25, 2011 at 00:43 UTC | |
by ikegami (Patriarch) on Oct 25, 2011 at 04:45 UTC | |
|
Re: fork : distinguish between different child?
by cartmanofvan (Initiate) on Oct 25, 2011 at 19:09 UTC |