in reply to Re: Threading Woes
in thread Threading Woes
my %hosts=(); my $counter=0; my $global=0; my $pool=(); my @result=(); my %ids=(); $pool = Thread::Pool->new( { do => sub {\&Temp_function(@_);}, workers => 10, # default: 1 }); %hosts = &Telnet_host(); foreach (keys %hosts) { $ids{$_}=$pool->job($_, $hosts{$_} ); } while (keys %ids) { foreach (keys %ids) { if (@result = $pool->result_dontwait($_)) { print $ids{$_} . "\n"; delete ($ids{$_}); } } print "Items still to do: " . $pool->todo . "\n"; } ##--END FUNCTION CALLs-- ### Temp Sub Functions sub Temp_function { my ($ip,$mac)= @_; print $mac . "\n"; return $mac; } ### End Temp Sub Functions
|
|---|