use strict; use warnings; my @orig = 1..2500; my $numberofarray = scalar @orig; my $arrs = 100; # Partition #print $arrs; sub Partition_Array_data { my @arrs; push @{$arrs[$_ % $arrs]}, $orig[$_] for 0..$#orig; if (my $pid = fork) { waitpid($pid, 0); } else { if (fork) { exit } else { thread_dbSave(\@arrs); } } } sub thread_dbSave { # this function will handle the saving my @arrayofsplit = @{$_[0]}; print join ' ', @$_, "\n" for @arrayofsplit; } &Partition_Array_data();