http://www.perlmonks.org?node_id=1020848

rahulruns has asked for the wisdom of the Perl Monks concerning the following question:

I have an array of host name on which I need to run a command to check the availability of rpms. The list of hosts is quiet big. Is it possible to rpm check command in parallel on all hosts? I have reduced the number of hosts in the code for better display. In actual I have 100 hosts

my @hosts = ("a01", "a02"); my @rpms = ("xx1", "xx2", "xx3", "xx4", "xx5", "xx6", "xx7"); print "CHECKING THE INSALLED RPM(s)\n"; foreach (@hosts) { my $host_name = $_; foreach (@rpms) { my $rpm; if ( "$_" eq "xx4" ) { $rpm = system ("ssh $host_name rpm -qa | grep $_ | grep -vi perl &>> $ +directory_create/rpm"); } else { $rpm = system ("ssh $host_name rpm -qa | grep $_ &>> $directory_create +/rpm"); } if ( $rpm == 0 ) { print " $_ RPM ................... IS PRESENT ON HOST \n"; } else { print " Exiting..................... "; exit 1; } } #foreach rpm loop }#foreach hosts loop ends here