It's another ugly hack, but I think you could use a string eval. Create the string dynamically, including locks to the variables you need and including the work to be done and the signalling, then eval the string. I'm not sure that's worth it just to avoid a goto call. (You may have just discovered a good use of goto.)
I had to figure out something similar in Object::LocalVars, except I needed to localize a bunch of things instead of locking them. In that case, though, the list of variables is known at compile time, so the eval installs a localizing subroutine only once and efficiency of string eval isn't an issue.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: Looping without introducing a block
by xdg
in thread Looping without introducing a block
by cmeyer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |