Saurabh Singhvi wrote:
Hi

Hello,


I have a script which executes some system commands one after the other. But

as can be seen from what is written the limitation is that they are executed
one
after the other. Now, I want them to run simultaneously. So, how should i go
about
doing it??

http://search.cpan.org/perldoc?Acme::Spork

use Acme::Spork;

my @commands = (
   ['do', 'this'],
   ['and', 'that'],
);

spork(sub { exec @_; }, @{ $_ }) for @commands;

# or for more control and slighlty more readable:

my @spids;
for my $cmd_ref(@commands) {

    push @spids, spork(sub {
                       exec @_
                   },
                   @{ $cmd_ref }
               );
}

# now you have all the command's PIDS in an aray to do with as you like :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to