Hi I'm trying to add multiple keys/values into a hash. Basically file names and their data. Each of the json file's content have hash and array referencing. The hash that contains the file names and data will be handled else where.
This is my code:
sub getDecode {
my $self = shift;
my @arrUrls = ('http://domain.com/test.json', 'http://domain.com/test_two.json', 'http://domain.com/test3.json');
my $resQueue = Thread::Queue->new();
my $intThreads = 10;
my @arrThreads = ();
my %arrInfo = ();
foreach my $strUrl (@arrUrls) {
for (1..$intThreads) {
push (@arrThreads, threads->create(sub {
while (my $resTask = $resQueue->dequeue) {
my $resData = get($strUrl);
my $strName = basename($strUrl, '.json');
my $arrData = decode_json($resData);
$arrInfo{$strName} = $arrData;
}
}));
}
}
$resQueue->enqueue(@arrUrls);
$resQueue->enqueue(undef) for 1..$intThreads;
$_->join for @arrThreads;
return %arrInfo;
}
When I try data dumping on %arrInfo
no output is given. Please help!