At 11:10 PM 6/17/01 -0400, Ronald J. Yacketta wrote: >I am a bit lost.. all the references to fork() are in the if/else context. > >so, I would wrap the fork code into a sub and then call that sub passing it >the array each time?? Not necessarily. But it would look neater. >please forgive my ignorance, I am but a newb > >Ron >rough code: > >if { $pid = fork ) { > parent here > } else { > child, do the tango? > } >} >wait Better figure out how you're going to get the results back into your parent from the children, since it looks like your child processes figure out something the parent wants to know. This part is often messy. Do perldoc perlipc and ruminate on that for a while to see what's going to be the best for for what you want to do. For a first shot, perhaps you just want to have each egrep send its results to a temporary file and then you can read 'em, so something like: dofork(...); dofork(...); dofork(...); wait; sub dofork { if (fork) { return; } else { exec (... something using @_, putting results in /tmp/something$$ ... ); } } perlipc will show you that it gets hairier than that the more robust and capable you want to make this kind of thing, there's some learning curve ahead. > > -----Original Message----- > > From: Peter Scott [mailto:[EMAIL PROTECTED]] > > Sent: June 17, 2001 23:01 > > To: [EMAIL PROTECTED]; Perl > > Subject: Re: fork > > > > > > At 05:35 PM 6/17/01 -0400, Ronald J. Yacketta wrote: > > >Folks, > > > > > >Can someone shed some light on using fork to spawn 2+ > > simultaneous process? > > >I am reading in allot of logfiles and splitting them into 3 > > separate arrays. > > >Currently I am forking and doing a exec("egrep", "-c", "Err", @array1); > > >(yes, ugly but it is just the beginning!) this works well > > >if I were to exec one at a time, I would like to fork and send all three > > >execs rolling at one. any clues? > > > > Just do three forks, each with its own exec. Then call wait() until > > they're all done. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com