goto EXPR
goto &NAME
sort.
It can be used to go almost anywhere else within the
dynamic scope, including out of subroutines, but it's usually better to use
some other construct such as last or die. The author of Perl has never felt
the need to use this form of goto (in Perl, that is--C is another matter).
The goto-EXPR form expects a label name, whose scope will be resolved dynamically. This allows for computed gotos per FORTRAN, but isn't necessarily recommended if you're optimizing for maintainability:
goto ("FOO", "BAR", "GLARCH")[$i];
The goto-&NAME form is highly magical, and substitutes a call to the named subroutine for the currently running subroutine. This is used by
AUTOLOAD subroutines that wish to load another subroutine and then pretend that the other subroutine had been called in the first place (except that any modifications to @_
in the current subroutine are propagated to the other subroutine.) After the goto, not even caller
will be able to tell that this routine was called first.