http://qs321.pair.com?node_id=859301

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

Requirement: Need to connect to multiple database and host remotely, get the data back and write into text file.
Approach : Thinking to use threads. Create thread pool of 20 threads and connect simultaneously and get data back. at present i am stuck, not able to ensure that how to get connection handle for each host/data server using threads.
Would be grateful if you can point me in right direction. Thanks example:
use strict; use threads; use Data::Dumper; use threads::shared; #number of service threads to create my $threads = 20; my %dataEntity = ('TEST' => "usr:passwd", 'TEST' => "usr:passwd" ); # create a pool of three service threads foreach (1.. $threads) { threads->create(\&getData); } ## foreach my $dataServer (keys %dataEntity){ ##not sure how will i use thread here } sub getData { my $self = threads->self; my $thread_line; ##how }