{ 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