I have an array of integers and the array size is variable ,it is determined at processing time.
What I need to do is to work out how many elements there are in the array and process each element with no more than 50 at a time.
So, if there are 320 elements, then I need to process them in 6 lots of 50, then process the last 20.
I was thinking of working out the total array size, if it's bigger than or equal to 50, then dividing by 50 to get the number of batches, but also work out the remainder
I guess I'm struggling to work out how to run commands in batches of 50 and also process the remaining elements.
Any help would be appreciated.
What I need to do is to work out how many elements there are in the array and process each element with no more than 50 at a time.
So, if there are 320 elements, then I need to process them in 6 lots of 50, then process the last 20.
I was thinking of working out the total array size, if it's bigger than or equal to 50, then dividing by 50 to get the number of batches, but also work out the remainder
Code:
@array = ("30,34,35,40,51.....") #variable size
$arraysize = $#array + 1;
$remainder = $arraysize % 50;
$iterations = sprintf("%d",$arraysize/50);
if ($arraysize >= 50){
for ($i=0,$1 < $iterations,$i++){
foreach $elem(0..$#arraysize) {
#run fork command
#get result
splice(@array,0,50); #should I splice the top 50 elements after every lot of commands?
}
}
}
I guess I'm struggling to work out how to run commands in batches of 50 and also process the remaining elements.
Any help would be appreciated.