in reply to A metaclosure? Howto?

Sounds like you're after a coroutine, which unfortunately is not natively supported in perl. You might want to check out the Coro module which implements them with some success, or wait around for Perl6 ;-)

Of course there's always TIMTOWTDI and you could try something like this ...

{ my $lex_sub; sub coro { my @lexvar = @_; $lex_sub = sub { print pop @lexvar, $/; return scalar @lexvar; } if not defined $lex_sub; $lex_sub->(); } } my @words = qw(foo bar baz quux); coro() while coro(@words); __output__ quux baz bar foo
But that is hackish, ugly and not much of a coroutine. I'd say stick with Coro or check out ruby for your coroutine fix.
HTH

_________
broquaint