in reply to Re: Entering and exiting subs in style
in thread Entering and exiting subs in style

As stated above, goto replaces the current call on the stack... In your code, I think it might be useful:

use strict; sub foo { goto &bar if ( $_[0] < 0 ); return "$_[0] from foo\n"; } sub bar { return "$_[0] from bar\n"; } print foo(-1);

If you run this code, you'll get -1 from bar\n as your output. Put simply, goto will replace the current call to &foo with a call to &bar. There are several limitations to this method, though... You can't pass &bar any parameters; &bar will be passed the arguments which &foo was called with. That being said, the second limitation is that you don't mess around with @_ in the calling subroutine... you'll surely regret it later. For further information, see pages 127 and 297 of The Bible.