
pavan6754
New User
Nov 7, 2011, 8:23 AM
Post #1 of 2
(641 views)
|
|
Issue with Threads while collecting command output
|
Can't Post
|
|
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 parllel )
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`; } Thanks in advance.
(This post was edited by pavan6754 on Nov 7, 2011, 8:42 AM)
|