in reply to A metaclosure? Howto?
Of course there's always TIMTOWTDI and you could try something like this ...
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.{ 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
_________
broquaint
|
|---|