in reply to Re: Maintaining context of the caller
in thread Maintaining context of the caller

Thanks for the ideas. I'll chew on them a while and see how they digest. A quick note about your more succinct way. As I also noted in my reply to ikegami, an even more succinct way would be:

sub foo { &$code }

The context would propagate automatically.

Update: to prove it to myself, I ran the following code:

$ perl -le ' my $code = sub { print wantarray ? "list" : "scalar" }; sub foo { &$code } () = foo; foo'

And it printed:

list scalar

Which verifies that the context propagates.