CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Issue with Threads while collecting command output: Edit Log

New User

Nov 7, 2011, 8:23 AM

Views: 1246
Issue with Threads while collecting command output

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");
push @threads, threads->create(\&execute_ls, $_);
foreach (@threads) {
while(($key,$val)=each %hash){
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)

Edit Log:
Post edited by pavan6754 (New User) on Nov 7, 2011, 8:42 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives