Perl has three goto forms: got LABLE, goto EXPR, and goto &NAME:
serial number | goto type |
---|---|
1 | goto LABEL Find the statement marked LABEL and re-execute it from there. |
2 | goto EXPR The goto EXPR form is just the general form of goto LABEL. It expects the expression to generate a tag name and jumps to that tag for execution. |
3 | goto&NAME It replaces the running child process with a call to the named child process. |
The syntax format is as follows:
goto LABEL or goto EXPR or goto &NAME
The following two examples jump out of the output when the variable $a is 15.
The following is a commonly used goto example:
Executing the above program, the output result is:
a = 10a = 11a = 12a = 13a = 14 jump out of the output a = 16a = 17a = 18a = 19
The following examples use the goto EXPR form. We used two strings and linked them using a period (.).
Executing the above program, the output result is:
a = 10a = 11a = 12a = 13a = 14a = 16a = 17a = 18a = 19