On 3/5/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote: > > > Saurabh Singhvi wrote: > > thanks for all the help!!!> > > > I am gonna try out all of them and settle with the best :). > > You'll likely want Acme::Spork's spork() because: > > a) You can run zillions of processes at the same time without waiting > for them (the fork recommendation will do one at a time as if you had > done: system($_) for @commands; so its not really what you wanted > assumgin I understood the OP) > > b) Its *spork*, how cool is it to go to your boss and say "Yes, er, Mr > BigPants I think our project would really benefit if we were to spork at > this juncture", seriously that is *cool* :)
Acme::Spork and fork() provide exactly the same base functionality: They're both front ends for the fork(2) system call. In fact, Acme::Spork fork(). You can see that the following snippets produce exactly the same results: use Acme::Spork; print 1; spork( sub { sleep 5; print "child\n" }, ); print "parent\n"; and the standard: my $child = fork (); unless ($child) { sleep 5; print "child\n"; } print "parent\n" if $child; fork() only exhibits the behavior you describe if you issue a blocking wait() or waitpid(). What Acme::Spork does is simplify the logic a bit when you want to fork multiple children to do different things. Since fork() creates and exact duplicate of the running process, you end up writing a lot of if block and setting a lot of flags to make your children behave differently. Acme::Spork makes it easier to fork a child to execute a specific bit of code by executing the fork from an external process that contains nothing except your coderef and the few lines of the Acme::Spork code itself. You pass it a coderef and let the module write the if-else block for you. This is very useful, particularly if you're spawning a lot of children for a program with a large resident memory size, but it's just a wrapper for fork(). HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!