Hi Guys,
Below Program creates 3 Threads and each execute ls command for given input path .But this program hangs,seems to be issue with executing ls command.can you please help me out here.
(Note: i don't want to use here lock,as it will be sequential execution not parallel )
use threads;
use threads::shared;
my %hash:shared =1;
my @array=("c:\\Myscripts","c:\\Temp","c:\\Dropbox");
foreach(@array){
push @threads, threads->create(\&execute_ls, $_);
}
foreach (@threads) {
$_->join();
}
while(($key,$val)=each %hash){
print("$key:$val\n");
}
sub execute_ls{
my $ip=shift;
$hash{$ip}=`ls -1 $ip`;
}