while (@array) { $item = shift @array; ... push @array, @newstuff; }