I just need a little clarification about yield().

consider this sub:

    sub iterate(@foo) {
        yield for @foo;
        undef;
    }

(Where yield defaults to the topic)  Presumably. 

    @a = (1, 2, 3, 4, 5);
    while($_ = iterate @a) {
        print
    }

Will print "12345".  Or is that:

    for @a {
        print
    }

?  So, does yield() build a lazy array, or does it act like an eplicit
iterator?  If the latter,  how do you tell the difference between a
recursive call and fetching the next element?  How would you maintain
two iterators into the same array?

Luke

Reply via email to