while(@array1) {
ONE: while(@array1) {
my $item = shift @array1;
# Do various things with $item, some of which will _possibly_
# push @array1, ...
# and/or
# push @array2, ...
}
TWO: while(@array2) {
my $item = shift @array2;
# Do various things with $item, some of which will _possibly_
# push @array2, ...
# and/or
# push @array1, ...
}
}
####
while(@array1 or @array2) {
my $i = 0;
ONE: while(@array1 and $i < $some_large_number/10) {
$i++;
my $item = shift @array1;
# Do various things (as above)
}
$i = 0;
TWO: while(@array2 and $i < $some_large_number) {
$i++;
my $item = shift @array2;
# Do various things (as above)
}
}
####
while(@array) {
my $item = shift @array;
if (used_to_be_in_array1($item)) {
# Do various array1ish things with $item, some of which will _possibly_: push @array, ...
} elsif (used_to_be_in_array2($item)) {
# Do various array2ish things with $item, some of which will _possibly_: push @array, ...
} else {
warn $item;
}
}