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

The following works if the call to the wrapped function is done at the end of the wrapping function

FYI, in the case of calling the wrapped sub at the end of the wrapper, one could simply do:

sub foo { # ... &$code; }

As for the goto version, that's a nice trick that I occasionally use, but isn't necessary in this case.

The following is a more general case

That's an excellent idea, always storing the results in an array and enforcing the context on the right hand side of the assignment. This is probably the approach I'll take. (Also, your explanation of the array slice wasn't necessary for me, but it's quite good, and others may benefit from it.)