August 1999 Return to the Perl Hardware Store Slide #34

Iterator Operations

        sub mingle {
          my @iterator = @_;
          my $next = 0;
          sub {
            my $line = $iterator[$next]->();
            $next = ($next + 1) % @iterator;
            $line;
          }
        }
        $new_it = mingle($it1, $it2, $it3);


Next Copyright © 1999 M-J. Dominus