I am using forkmanager to run tasks at the same time instead of sequentially. I have turned my actual code into the following example code that represents my code's logic.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use Parallel::ForkManager;
my @array2d = () ;
my $dim1Items = 4;
my $dim2Items = 3;
my $dim1Manager = Parallel::ForkManager->new($dim1Items);
for (my $i = 0; $i <= $dim1Items ; $i++) {
$dim1Manager->start and next;
my $dim2Manager = Parallel::ForkManager->new($dim2Items);
for (my $j = 0; $j <= $dim2Items; $j++) {
$dim2Manager->start and next;
$array2d[$i][$j] = "$i\t$j" ;
$dim2Manager->finish;
}
$dim2Manager->wait_all_children;
$dim1Manager->finish;
}
$dim1Manager->wait_all_children;
print Dumper(@array2D) ;
Then I run Dumper(@2dArray) to see the contents, but I get the null string, meaning the array is empty. I tried my value assignment syntax without forking and it works - so I must be doing something wrong in forking.