My understanding of goto &s1 is that control is transfered to the subroutine s1 without any change in the stack.
Read the docs!
it exits the current subroutine (losing any changes set by local()) and immediately calls in its place the named subroutine using the current value of @_.
"No changes to @_" is not "no changes to the stack". Quite the opposite, the goal of goto &name is to remove the current stack frame.
You want just &name;, not goto &name;. It preserves @_ without removing the current stack frame.
sub s1 { our $var; print "arg: $_[0]\n"; print "local: $var\n"; } sub s0 { local our $var = 'local'; &s1; } s0('arg');
arg: arg local: local
Update: Initially, I accidentally left out the bit about &name;. Added.
In reply to Re: goto &sub and local question
by ikegami
in thread goto &sub and local question
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |