How to launch many programs sequentially without being block?

In unix system

I have a directory called program_sets , and in the program_sets , there exists 8 directory and in each directory they have a program called A.pl

I want to launch and run 8 A.pl programs in the same time , but when I launch the first program , the procedure will be block until the first program call is finish . How can I solve this problems?

here is my code

#!/usr/bin/perl

opendir(Programs,"./program_sets");
@Each_names = readdir(Programs);
shift(@Each_names);
shift(@Each_names);

for($i=0;$i<=$#Each_names;$i++)
{
    `perl ./program_sets/$Each_names[$i]/A.pl`;
}

thanks

Answers


Run them in the background with &, just like you would from the shell.

for($i=0;$i<=$#Each_names;$i++)
{
    system("perl ./program_sets/$Each_names[$i]/A.pl >/dev/null 2>&1 &");
}

Also, backticks should be used when you're assigning the output to a variable. Use system() to run a command without saving the output.


Need Your Help

Comparing hash causing issues

php sql-server hash

I have a site that I am storing the username and hashed password in a table. I am trying to compair this information (username and hashed password) to the login information passed from my login site.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.